-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
56 lines (50 loc) · 1.42 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
const BrotliPlugin = require("brotli-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const zopfli = require("@gfx/zopfli");
const webpack = require('webpack')
const handler = (percentage, message, ...args) => {
// e.g. Output each progress message directly to the console:
console.info(percentage*100, message, ...args);
};
let plugins = [];
if (process.env.NODE_ENV === "production") {
const compressionTest = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i;
plugins = [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1, // Must be greater than or equal to one
minChunkSize:150
}),
new CompressionPlugin({
algorithm(input, compressionOptions, callback) {
return zopfli.gzip(input, compressionOptions, callback);
},
compressionOptions: {
numiterations: 15
},
minRatio: 0.99,
test: compressionTest
}),
new BrotliPlugin({
test: compressionTest,
minRatio: 0.99
}),
new webpack.ProgressPlugin(handler)
];
}
module.exports = {
baseUrl: process.env.BASE_URL,
productionSourceMap: false,
configureWebpack: {
plugins
},
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
},
}