-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
150 lines (137 loc) · 3.81 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
'use strict'
const path = require('path')
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin') // gzip压缩
const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i // gzip匹配文件规则
const BranchVersionWebpackPlugin = require('./webpack-plugin/branch-version-webpack-plugin')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const {
ElementPlusResolver
} = require('unplugin-vue-components/resolvers')
const NOT_DEV = process.env.NODE_ENV !== 'development'
const globalConfig = require('./src/config/index.js')
const resolve = dir => path.join(__dirname, dir)
const addOptions = {
preserveWhitespace: true
}
const externals = {
'web3': 'Web3'
}
module.exports = {
publicPath: process.env.NODE_ENV === 'testnet' ? '' : '/',
outputDir: process.env.VUE_APP_OUTPUTDIR,
runtimeCompiler: true,
productionSourceMap: false,
css: {
loaderOptions: {
less: {
javascriptEnabled: true,
lessOptions: {
// 在这里添加自定义的Less配置
},
}
}
},
configureWebpack: (config) => {
config.name = globalConfig.baseTitle
config.entry.app = ['babel-polyfill', './src/main.js'];
let plugins = [
new UglifyJsPlugin({
uglifyOptions: {
warnings: false,
compress: {
drop_console: true,
drop_debugger: true
},
output: {
comments: false,
}
},
sourceMap: false,
parallel: true,
}),
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: productionGzipExtensions,
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false
}),
new webpack.DefinePlugin({
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false)
}),
AutoImport({
resolvers: [ElementPlusResolver({
exclude: new RegExp(/^(?!.*loading-directive).*$/)
})]
}),
Components({
resolvers: [ElementPlusResolver()],
})
]
Object.assign(config, {
externals,
})
if (NOT_DEV) {
config.mode = 'production';
config.plugins = [...config.plugins, ...plugins];
config.performance = {
maxEntrypointSize: 10000000,
maxAssetSize: 30000000
}
config.plugins.push(new BranchVersionWebpackPlugin());
}
},
chainWebpack: (config) => {
config.resolve.alias
.set('@', resolve('src'))
.set('@api', resolve('src/api'))
.set('@assets', resolve('src/assets'))
.set('@components', resolve('src/components'))
.set('@router', resolve('src/router'))
.set('@store', resolve('src/store'))
.set('@utils', resolve('src/utils'))
.set('@views', resolve('src/views'))
.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js')
.set('@public', resolve('public'));
config.output.filename('[name].[hash].js').end();
config.module
.rule("vue")
.use("vue-loader")
.loader("vue-loader")
.tap(options => {
// modify the options...
options.compilerOptions = addOptions;
return options;
});
},
devServer: {
port: 8080,
open: true,
// proxy: {
// '/api': {
// target: 'http://18.221.71.211:5000/',
// ws: true,
// changeOrigin: true,
// secure: false,
// pathRewrite: {
// '^/api': ''
// }
// },
// }
},
pluginOptions: {
i18n: {
locale: 'en',
fallbackLocale: 'zn',
localeDir: 'locales',
enableLegacy: true,
runtimeOnly: false,
compositionOnly: true,
fullInstall: true
}
}
}