@@ -8,6 +8,7 @@ The server config is meant for generating the server bundle that will be passed
8
8
9
9
``` js
10
10
const merge = require (' webpack-merge' )
11
+ const nodeExternals = require (' wepback-node-externals' )
11
12
const baseConfig = require (' ./webpack.base.config.js' )
12
13
const VueSSRServerPlugin = require (' vue-server-renderer/server-plugin' )
13
14
@@ -29,21 +30,14 @@ module.exports = merge(baseConfig, {
29
30
},
30
31
31
32
// https://webpack.js.org/configuration/externals/#function
33
+ // https://github.com/liady/webpack-node-externals
32
34
// Externalize app dependencies. This makes the server build much faster
33
35
// and generates a smaller bundle file.
34
- externals : (context , request , cb ) => {
35
- // a module is externalized if...
36
- if (
37
- // it's inside node_modules
38
- / node_modules/ .test (context) &&
39
- // ... and not a CSS file, in case we need to import CSS from a dependency
40
- ! / \. (css| styl(us)? | less| sass| scss)(\? [^ . ] + )? $ / .test (request)
41
- ) {
42
- cb (null , ` commonjs ${ request} ` )
43
- } else {
44
- cb ()
45
- }
46
- },
36
+ externals: nodeExternals ({
37
+ // do not externalize dependencies that need to be processed by webpack.
38
+ // you can add more file types here e.g. raw *.vue files
39
+ whitelist: / \. css$ /
40
+ }),
47
41
48
42
// This is the plugin that turns the entire output of the server build
49
43
// into a single JSON file. The default file name will be
0 commit comments