-
Notifications
You must be signed in to change notification settings - Fork 18
/
vue.config.js
77 lines (77 loc) · 1.9 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
const CompressionPlugin = require('compression-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
const pkg = require('./package.json')
const isPord = process.env.NODE_ENV === 'production'
const current = 'admin'
const pages = [
// development
// can only debug one
{
index: {
entry: `src/pages/${current}/main.js`,
title: pkg.title,
filename: 'index.html',
},
},
// production
{
index: {
entry: 'src/pages/admin/main.js',
title: pkg.title,
filename: 'admin/index.html',
},
query: {
entry: 'src/pages/query/main.js',
title: pkg.title,
filename: 'query/index.html',
},
},
]
module.exports = {
publicPath: isPord ? '/' : '/',
pages: pages[isPord ? 1 : 0],
lintOnSave: !isPord,
productionSourceMap: false,
css: {
extract: true,
sourceMap: false,
loaderOptions: {
sass: {
data: `@import "@/common/styles/_app.scss";`,
},
},
},
devServer: {
host: '0.0.0.0',
port: 8080,
https: false,
hotOnly: true,
},
configureWebpack: config => {
const pluginsPro = [
new CompressionPlugin({
test: /\.js$|\.html$|.\css/,
threshold: 10240,
deleteOriginalAssets: false,
}),
]
if (process.env.npm_config_report) {
pluginsPro.push(new BundleAnalyzerPlugin())
}
const pluginsDev = []
if (isPord) {
config.plugins = [...config.plugins, ...pluginsPro]
} else {
config.plugins = [...config.plugins, ...pluginsDev]
}
},
chainWebpack: config => {
config.plugin('define').tap(definitions => {
definitions[0]['process.env']['APP_NAME'] = JSON.stringify(pkg.name)
definitions[0]['process.env']['APP_TITLE'] = JSON.stringify(pkg.title)
definitions[0]['process.env']['APP_VERSION'] = JSON.stringify(pkg.version)
return definitions
})
},
}