-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.client.config.js
56 lines (51 loc) · 1.72 KB
/
webpack.client.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin');
const { getBaseConfig, isProd } = require('./webpack.base.config');
module.exports = function getClientConfig(configOpts) {
const config = {
type: 'client',
rootDir: null,
extractCss: false,
cssInsert: null,
enablePostCss: false,
postCssOpts: null,
i18nBlocks: false,
theme: null,
sassLoaderData: null,
babelLoader: true,
terserOptions: null,
terserPluginOptions: null,
svgInlineLoaderOptions: null,
...configOpts,
};
const clientConfig = merge(getBaseConfig(config), {
name: 'client',
devtool: isProd ? 'source-map' : 'eval-source-map',
entry: {
app: './src/js/entry-client.js',
},
plugins: [
new webpack.DefinePlugin({ 'process.env.VUE_ENV': '"client"' }),
new VueSSRClientPlugin(),
],
...(config.extractCss && isProd ? {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
safari10: true,
...config.terserOptions,
},
...config.terserPluginOptions,
}),
// Minimize extracted CSS files
new OptimizeCSSAssetsPlugin({}),
],
},
} : {}),
});
return clientConfig;
};