diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index bb720aced4..ef56af0ad4 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -55,13 +55,13 @@ export default function webpackBaseConfig ({ isClient, isServer }) { 'assets': join(this.options.srcDir, 'assets') // use in template with }, modules: [ - join(this.options.rootDir, 'node_modules'), + this.options.modulesDir, nodeModulesDir ] }, resolveLoader: { modules: [ - join(this.options.rootDir, 'node_modules'), + this.options.modulesDir, nodeModulesDir ] }, diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index 94e6d593b5..1b8402caa2 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -39,7 +39,8 @@ export default function webpackServerConfig () { // https://github.com/liady/webpack-node-externals nodeExternals({ // load non-javascript files with extensions, presumably via loaders - whitelist: [/\.(?!(?:js|json)$).{1,5}$/i] + whitelist: [/\.(?!(?:js|json)$).{1,5}$/i], + modulesDir: this.options.modulesDir }) ], plugins: (config.plugins || []).concat([ diff --git a/lib/common/options.js b/lib/common/options.js index 71b55dabcc..1464c9862e 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -25,8 +25,10 @@ export default function Options (_options) { _.defaultsDeep(options, Options.defaults) // Resolve dirs - options.rootDir = (typeof options.rootDir === 'string' && options.rootDir ? options.rootDir : process.cwd()) - options.srcDir = (typeof options.srcDir === 'string' && options.srcDir ? resolve(options.rootDir, options.srcDir) : options.rootDir) + const hasValue = v => typeof v === 'string' && v + options.rootDir = hasValue(options.rootDir) ? options.rootDir : process.cwd() + options.srcDir = hasValue(options.srcDir) ? resolve(options.rootDir, options.srcDir) : options.rootDir + options.modulesDir = resolve(options.rootDir, hasValue(options.modulesDir) ? options.modulesDir : 'node_modules') options.buildDir = join(options.rootDir, options.buildDir) // If app.html is defined, set the template path to the user template