fix: replace nuxtDir with module.paths (#4448)

Co-authored-by: Pooya Parsa <pooya@pi0.ir>
Co-authored-by: Clark Du <clark.duxin@gmail.com>
This commit is contained in:
Pooya Parsa 2018-11-29 16:46:46 +03:30 committed by Clark Du
parent 2f1e0045cc
commit d66e1ec896
2 changed files with 6 additions and 9 deletions

View File

@ -1,5 +1,3 @@
import path from 'path'
import fs from 'fs'
import capitalize from 'lodash/capitalize'
import env from 'std-env'
@ -31,9 +29,6 @@ export default () => ({
// Dirs and extensions
srcDir: undefined,
buildDir: '.nuxt',
nuxtDir: fs.existsSync(path.resolve(__dirname, '..', '..', 'package.js'))
? path.resolve(__dirname, '..', '..') // src
: path.resolve(__dirname, '..'), // dist
modulesDir: [
'node_modules'
],

View File

@ -4,6 +4,7 @@ import defaultsDeep from 'lodash/defaultsDeep'
import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import uniq from 'lodash/uniq'
import consola from 'consola'
import { guardDir, isNonEmptyString, isPureObject, isUrl } from '@nuxt/common'
import { getDefaultNuxtConfig } from './config'
@ -97,10 +98,11 @@ export function getNuxtConfig(_options) {
}
// Populate modulesDir
options.modulesDir = []
.concat(options.modulesDir)
.concat(path.join(options.nuxtDir, 'node_modules')).filter(isNonEmptyString)
.map(dir => path.resolve(options.rootDir, dir))
options.modulesDir = uniq(
require.main.paths.concat(
[].concat(options.modulesDir).map(dir => path.resolve(options.rootDir, dir))
)
)
const mandatoryExtensions = ['js', 'mjs']