diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index 5a923d6390..451e70c304 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -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 diff --git a/lib/common/options.js b/lib/common/options.js index 39c8e3b12c..04b37660b6 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -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')