fix: allow force overriding resolve paths (#8936)

[release]
This commit is contained in:
pooya parsa 2021-03-05 18:19:26 +01:00 committed by GitHub
parent f56a2c6785
commit 94fff623f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -28,7 +28,7 @@ export default class Resolver {
resolveModule (path, { paths } = {}) {
try {
return this._require.resolve(path, {
paths: [].concat(paths || [], this.options.modulesDir, global.__NUXT_PATHS__ || [], process.cwd())
paths: [].concat(global.__NUXT_PREPATHS__ || [], paths || [], this.options.modulesDir, global.__NUXT_PATHS__ || [], process.cwd())
})
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {

View File

@ -77,7 +77,7 @@ export function resolveModule (id, paths) {
paths = [paths]
}
return _require.resolve(id, {
paths: [].concat(paths || [], global.__NUXT_PATHS__ || [], process.cwd())
paths: [].concat(...(global.__NUXT_PREPATHS__ || []), paths || [], global.__NUXT_PATHS__ || [], process.cwd())
})
}

View File

@ -227,6 +227,7 @@ export default class WebpackBaseConfig {
const webpackModulesDir = ['node_modules'].concat(this.buildContext.options.modulesDir)
const resolvePath = [
...(global.__NUXT_PREPATHS__ || []),
this.buildContext.options.rootDir,
__dirname,
...(global.__NUXT_PATHS__ || []),