diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 1ea3eecd6a..bc12f57a12 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -16,6 +16,9 @@ const WarnFixPlugin = require('./plugins/warnfix') |-------------------------------------------------------------------------- */ module.exports = function webpackBaseConfig({ name, isServer }) { + // Prioritize nested node_modules in webpack search path (#2558) + const webpackModulesDir = ['node_modules'].concat(this.options.modulesDir) + const config = { name, entry: { @@ -25,9 +28,9 @@ module.exports = function webpackBaseConfig({ name, isServer }) { path: resolve(this.options.buildDir, 'dist'), filename: this.getFileName('app'), chunkFilename: this.getFileName('chunk'), - publicPath: (isUrl(this.options.build.publicPath) + publicPath: isUrl(this.options.build.publicPath) ? this.options.build.publicPath - : urlJoin(this.options.router.base, this.options.build.publicPath)) + : urlJoin(this.options.router.base, this.options.build.publicPath) }, performance: { maxEntrypointSize: 1000000, @@ -43,13 +46,13 @@ module.exports = function webpackBaseConfig({ name, isServer }) { '@@': join(this.options.rootDir), // Used by vue-loader so we can use in templates // with - 'assets': join(this.options.srcDir, 'assets'), - 'static': join(this.options.srcDir, 'static') + assets: join(this.options.srcDir, 'assets'), + static: join(this.options.srcDir, 'static') }, - modules: this.options.modulesDir + modules: webpackModulesDir }, resolveLoader: { - modules: this.options.modulesDir + modules: webpackModulesDir }, module: { noParse: /es6-promise\.js$/, // Avoid webpack shimming process @@ -67,9 +70,18 @@ module.exports = function webpackBaseConfig({ name, isServer }) { }, { test: /\.css$/, use: styleLoader.call(this, 'css') }, { test: /\.less$/, use: styleLoader.call(this, 'less', 'less-loader') }, - { test: /\.sass$/, use: styleLoader.call(this, 'sass', {loader: 'sass-loader', options: { indentedSyntax: true }}) }, + { + test: /\.sass$/, + use: styleLoader.call(this, 'sass', { + loader: 'sass-loader', + options: { indentedSyntax: true } + }) + }, { test: /\.scss$/, use: styleLoader.call(this, 'scss', 'sass-loader') }, - { test: /\.styl(us)?$/, use: styleLoader.call(this, 'stylus', 'stylus-loader') }, + { + test: /\.styl(us)?$/, + use: styleLoader.call(this, 'stylus', 'stylus-loader') + }, { test: /\.(png|jpe?g|gif|svg)$/, loader: 'url-loader',