refactors for modulesDir as array

This commit is contained in:
Pooya Parsa 2017-11-24 13:10:01 +03:30
parent f27ddea7d5
commit 259f26bd4f
No known key found for this signature in database
GPG Key ID: C3C77C557D8883CD
2 changed files with 8 additions and 15 deletions

View File

@ -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

View File

@ -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')