diff --git a/packages/webpack/src/config/server.js b/packages/webpack/src/config/server.js index 9f8b9f876e..d921c43304 100644 --- a/packages/webpack/src/config/server.js +++ b/packages/webpack/src/config/server.js @@ -7,6 +7,11 @@ import VueSSRServerPlugin from '../plugins/vue/server' import WebpackBaseConfig from './base' +const nativeFileExtensions = [ + '.json', + '.js' +] + export default class WebpackServerConfig extends WebpackBaseConfig { constructor (...args) { super(...args) @@ -20,11 +25,23 @@ export default class WebpackServerConfig extends WebpackBaseConfig { get externalsWhitelist () { return [ - /\.(?!js(x|on)?$)/i, + this.isNonNativeImport.bind(this), ...this.normalizeTranspile() ] } + /** + * files *not* ending on js|json should be processed by webpack + * + * this might generate false-positives for imports like + * - "someFile.umd" (actually requiring someFile.umd.js) + * - "some.folder" (some.folder being a directory containing a package.json) + */ + isNonNativeImport (modulePath) { + const extname = path.extname(modulePath) + return extname !== '' && !nativeFileExtensions.includes(extname) + } + env () { return Object.assign( super.env(),