-
Notifications
You must be signed in to change notification settings - Fork 16
/
vue.config.js
79 lines (75 loc) · 2.11 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
const CircularDependencyPlugin = require("circular-dependency-plugin");
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const webpack = require("webpack");
const supportedLocales = require("./src/locales");
let codes = [];
for (const code in supportedLocales) {
const locale = supportedLocales[code];
codes.push(locale.fns.code);
}
process.env.VUE_APP_VERSION = require('./package.json').version
module.exports = {
chainWebpack: config => {
config.optimization.minimizer("terser").tap(args => {
args[0].terserOptions.output = {
...args[0].terserOptions.output,
comments: false, // exclude all comments from output
ascii_only: true
};
return args;
});
},
pluginOptions: {
webpackBundleAnalyzer: {
analyzerMode: process.env.VUE_APP_MODE === "production" ? "disabled" : "static",
// openAnalyzer: process.env.VUE_APP_MODE === "production" ? false : true,
openAnalyzer: false,
},
i18n: {
locale: "en",
fallbackLocale: "en",
localeDir: "locales",
enableInSFC: true,
},
},
configureWebpack: {
plugins: [
new webpack.ContextReplacementPlugin(
/date\-fns[\/\\]/,
new RegExp(`[/\\\\\](${codes.join("|")})[/\\\\\]index\.js$`)
),
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/,
failOnError: true,
allowAsyncCycles: false,
cwd: process.cwd(),
}),
new ReplaceInFileWebpackPlugin([{
dir: 'dist/static/img',
files: ['sheet.json', 'sheet_holiday.json'],
rules: [
{
search: '"image": "sheet.png"',
replace: '"image": "sheet.png?v=' + process.env.VUE_APP_VERSION + '"'
},
{
search: '"image": "characters.png"',
replace: '"image": "characters.png?v=' + process.env.VUE_APP_VERSION + '"'
},
{
search: '"image": "mall.png"',
replace: '"image": "mall.png?v=' + process.env.VUE_APP_VERSION + '"'
},
{
search: '"image": "sheet_holiday.png"',
replace: '"image": "sheet_holiday.png?v=' + process.env.VUE_APP_VERSION + '"'
}]
}])
],
},
publicPath: "/",
outputDir: "dist",
runtimeCompiler: true,
assetsDir: "static",
productionSourceMap: false,
};