diff --git a/lib/index.js b/lib/index.js index 3eaa7e5da7..be18d9cbef 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,5 @@ require('dotenv').config(); +require('module-alias/register'); const config = require('./config'); const Koa = require('koa'); const fs = require('fs'); diff --git a/lib/routes/hpoi/index.js b/lib/routes/hpoi/index.js index 7245002b4b..c22c246993 100644 --- a/lib/routes/hpoi/index.js +++ b/lib/routes/hpoi/index.js @@ -1,4 +1,4 @@ -const axios = require('../../utils/axios'); +const axios = require('@/utils/axios'); const cheerio = require('cheerio'); const host = 'https://www.hpoi.net'; diff --git a/package.json b/package.json index 83c39e73de..79ded7147f 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "luxon": "1.13.2", "lz-string": "1.4.4", "markdown-it": "8.4.2", + "module-alias": "^2.2.0", "node-fetch": "2.5.0", "path-to-regexp": "3.0.0", "pidusage": "2.0.17", @@ -109,6 +110,12 @@ "!lib/routes/**/*.js" ], "bail": true, - "testEnvironment": "node" + "testEnvironment": "node", + "moduleNameMapper": { + "@/(.*)": "/lib/$1" + } + }, + "_moduleAliases": { + "@": "./lib" } } diff --git a/yarn.lock b/yarn.lock index 6beb3b0b38..980c5fca82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6658,6 +6658,11 @@ mockdate@2.0.2: resolved "https://registry.yarnpkg.com/mockdate/-/mockdate-2.0.2.tgz#5ae0c0eaf8fe23e009cd01f9889b42c4f634af12" integrity sha1-WuDA6vj+I+AJzQH5iJtCxPY0rxI= +module-alias@^2.2.0: + version "2.2.0" + resolved "https://registry.npm.taobao.org/module-alias/download/module-alias-2.2.0.tgz#a2e32275381642252bf0c51405f7a09a367479b5" + integrity sha1-ouMidTgWQiUr8MUUBfegmjZ0ebU= + move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"