-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
88 lines (86 loc) · 2.29 KB
/
vue.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const CompressionPlugin = require('compression-webpack-plugin');
const BrotliPlugin = require('brotli-webpack-plugin');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
module.exports = {
filenameHashing: true,
css: {
loaderOptions: {
sass: {
implementation: require('sass'),
},
},
},
chainWebpack: (config) => {
config.module
.rule('csv')
.test(/\.(csv)(\?.*)?$/)
.use('url-loader')
.loader('url-loader')
.tap(() => {
const options = {
limit: 8192,
mimetype: false,
};
return options;
});
config.module
.rule('shp')
.test(/\.(shp)(\?.*)?$/)
.use('raw-loader')
.loader('raw-loader');
return config;
},
configureWebpack: (config) => {
console.log(`NODE_ENV ${process.env.NODE_ENV}`);
if (process.env.NODE_ENV === 'production') {
config.optimization = {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/,
)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
};
const imagemin = new ImageMinimizerPlugin({
minimizerOptions: {
// Lossless optimization with custom option
severityError: 'warning',
plugins: [
['gifsicle', { interlaced: true }],
['jpegtran', { progressive: true }],
['optipng', { optimizationLevel: 5 }],
[
'svgo',
{
plugins: [
{
removeViewBox: false,
},
],
},
],
],
},
});
config.plugins.push(imagemin);
const brotli = new BrotliPlugin({
asset: '[path].br[query]',
test: /\.(js|css|html|svg)$/,
minRatio: 0.8,
});
config.plugins.push(brotli);
config.plugins.push(new CompressionPlugin());
}
},
};