enable nodeExternals for modulesDir if exists

#1076
This commit is contained in:
Pooya Parsa 2017-08-01 03:58:53 +04:30
parent 92b6936811
commit 5aa4120c3d

View File

@ -3,6 +3,7 @@ import VueSSRServerPlugin from 'vue-server-renderer/server-plugin'
import nodeExternals from 'webpack-node-externals'
import { each } from 'lodash'
import { resolve } from 'path'
import { existsSync } from 'fs'
import base from './base.config.js'
/*
@ -34,15 +35,7 @@ export default function webpackServerConfig () {
hints: false,
maxAssetSize: Infinity
},
externals: [
// https://webpack.js.org/configuration/externals/#externals
// https://github.com/liady/webpack-node-externals
nodeExternals({
// load non-javascript files with extensions, presumably via loaders
whitelist: [/\.(?!(?:js|json)$).{1,5}$/i],
modulesDir: this.options.modulesDir
})
],
externals: [],
plugins: (config.plugins || []).concat([
new VueSSRServerPlugin({
filename: 'server-bundle.json'
@ -56,6 +49,16 @@ export default function webpackServerConfig () {
])
})
// https://webpack.js.org/configuration/externals/#externals
// https://github.com/liady/webpack-node-externals
if (existsSync(this.options.modulesDir)) {
config.externals.push(nodeExternals({
// load non-javascript files with extensions, presumably via loaders
whitelist: [/\.(?!(?:js|json)$).{1,5}$/i],
modulesDir: this.options.modulesDir
}))
}
// --------------------------------------
// Production specific config
// --------------------------------------