mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
refactors for modulesDir as array
This commit is contained in:
parent
f27ddea7d5
commit
259f26bd4f
@ -52,12 +52,7 @@ export default function webpackServerConfig() {
|
||||
|
||||
// https://webpack.js.org/configuration/externals/#externals
|
||||
// https://github.com/liady/webpack-node-externals
|
||||
const moduleDirs = [
|
||||
...this.options.modulesDir
|
||||
// Temporary disabled due to vue-server-renderer module search limitations
|
||||
// resolve(__dirname, '..', 'node_modules')
|
||||
]
|
||||
moduleDirs.forEach(dir => {
|
||||
this.options.modulesDir.forEach(dir => {
|
||||
if (existsSync(dir)) {
|
||||
config.externals.push(nodeExternals({
|
||||
// load non-javascript files with extensions, presumably via loaders
|
||||
|
@ -42,16 +42,14 @@ Options.from = function (_options) {
|
||||
options.buildDir = resolve(options.rootDir, options.buildDir)
|
||||
options.cacheDir = resolve(options.rootDir, options.cacheDir)
|
||||
|
||||
if (Array.isArray(options.modulesDir) && options.modulesDir.length) {
|
||||
options.modulesDir = options.modulesDir.reduce((modules, dir) => {
|
||||
if (hasValue(dir)) {
|
||||
modules.push(resolve(options.rootDir, dir))
|
||||
}
|
||||
return modules
|
||||
}, [])
|
||||
} else {
|
||||
options.modulesDir = [resolve(options.rootDir, hasValue(options.modulesDir) ? options.modulesDir : 'node_modules')]
|
||||
// Normalize modulesDir
|
||||
if (!Array.isArray(options.modulesDir)) {
|
||||
options.modulesDir = [options.modulesDir]
|
||||
}
|
||||
if (!options.modulesDir.length) {
|
||||
options.modulesDir = ['node_modules']
|
||||
}
|
||||
options.modulesDir = options.modulesDir.filter(dir => hasValue(dir)).map(dir => resolve(options.rootDir, dir))
|
||||
|
||||
// If app.html is defined, set the template path to the user template
|
||||
options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html')
|
||||
|
Loading…
Reference in New Issue
Block a user