mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +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://webpack.js.org/configuration/externals/#externals
|
||||||
// https://github.com/liady/webpack-node-externals
|
// https://github.com/liady/webpack-node-externals
|
||||||
const moduleDirs = [
|
this.options.modulesDir.forEach(dir => {
|
||||||
...this.options.modulesDir
|
|
||||||
// Temporary disabled due to vue-server-renderer module search limitations
|
|
||||||
// resolve(__dirname, '..', 'node_modules')
|
|
||||||
]
|
|
||||||
moduleDirs.forEach(dir => {
|
|
||||||
if (existsSync(dir)) {
|
if (existsSync(dir)) {
|
||||||
config.externals.push(nodeExternals({
|
config.externals.push(nodeExternals({
|
||||||
// load non-javascript files with extensions, presumably via loaders
|
// 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.buildDir = resolve(options.rootDir, options.buildDir)
|
||||||
options.cacheDir = resolve(options.rootDir, options.cacheDir)
|
options.cacheDir = resolve(options.rootDir, options.cacheDir)
|
||||||
|
|
||||||
if (Array.isArray(options.modulesDir) && options.modulesDir.length) {
|
// Normalize modulesDir
|
||||||
options.modulesDir = options.modulesDir.reduce((modules, dir) => {
|
if (!Array.isArray(options.modulesDir)) {
|
||||||
if (hasValue(dir)) {
|
options.modulesDir = [options.modulesDir]
|
||||||
modules.push(resolve(options.rootDir, dir))
|
|
||||||
}
|
|
||||||
return modules
|
|
||||||
}, [])
|
|
||||||
} else {
|
|
||||||
options.modulesDir = [resolve(options.rootDir, hasValue(options.modulesDir) ? options.modulesDir : 'node_modules')]
|
|
||||||
}
|
}
|
||||||
|
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
|
// If app.html is defined, set the template path to the user template
|
||||||
options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html')
|
options.appTemplatePath = resolve(options.buildDir, 'views/app.template.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user