From 56db988f279a8f3737a2177bb0f3bbf23b350ae6 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 31 Jul 2018 14:10:24 +0100 Subject: [PATCH] feat: exclude build.transpile in server node externals (#3614) --- lib/builder/webpack/base.js | 4 ++-- lib/builder/webpack/server.js | 3 ++- lib/common/options.js | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/builder/webpack/base.js b/lib/builder/webpack/base.js index 1b67214be1..236c8a6cfb 100644 --- a/lib/builder/webpack/base.js +++ b/lib/builder/webpack/base.js @@ -142,9 +142,9 @@ export default class WebpackBaseConfig { exclude: file => { // not exclude files outside node_modules if (/node_modules/.test(file)) { - for (let pkg of this.options.build.transpile) { + for (let module of [/\.vue\.js/].concat(this.options.build.transpile)) { // item in transpile can be string or regex object - if (new RegExp(pkg).test(file)) { + if (module.test(file)) { return false } } diff --git a/lib/builder/webpack/server.js b/lib/builder/webpack/server.js index b966234844..404d1735c6 100644 --- a/lib/builder/webpack/server.js +++ b/lib/builder/webpack/server.js @@ -67,7 +67,8 @@ export default class WebpackServerConfig extends BaseConfig { whitelist: [ /es6-promise|\.(?!(?:js|json)$).{1,5}$/i, /\.css$/, - /\?vue&type=style/ + /\?vue&type=style/, + ...this.options.build.transpile ], modulesDir: dir }) diff --git a/lib/common/options.js b/lib/common/options.js index ce00835594..51508dd2de 100644 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -192,7 +192,8 @@ Options.from = function (_options) { } // include SFCs in node_modules - options.build.transpile = [/\.vue\.js/].concat(options.build.transpile || []) + options.build.transpile = [].concat(options.build.transpile || []) + .map(module => module instanceof RegExp ? module : new RegExp(module)) return options }