forked from zxwk1998/vue-admin-better
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
177 lines (169 loc) · 4.24 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* @author chuzhixin [email protected]
* @description vue.config.js全局配置
*/
const path = require('path')
const {
/* baseURL, */
publicPath,
assetsDir,
outputDir,
lintOnSave,
transpileDependencies,
title,
abbreviation,
devPort,
providePlugin,
build7z,
donation,
} = require('./src/config')
const { webpackBarName, webpackBanner, donationConsole } = require('vab-config')
if (donation) donationConsole()
const { version, author } = require('./package.json')
const Webpack = require('webpack')
const WebpackBar = require('webpackbar')
const FileManagerPlugin = require('filemanager-webpack-plugin')
const dayjs = require('dayjs')
const date = dayjs().format('YYYY_M_D')
const time = dayjs().format('YYYY-M-D HH:mm:ss')
process.env.VUE_APP_TITLE = title || '租立拍后台管理系统'
process.env.VUE_APP_AUTHOR = author || 'chuzhixin'
process.env.VUE_APP_UPDATE_TIME = time
process.env.VUE_APP_VERSION = version
const resolve = (dir) => {
return path.join(__dirname, dir)
}
const mockServer = () => {
if (process.env.NODE_ENV === 'development') {
return require('./mock/mockServer.js')
} else {
return ''
}
}
module.exports = {
publicPath,
assetsDir,
outputDir,
lintOnSave,
transpileDependencies,
devServer: {
hot: true,
port: devPort,
open: true,
noInfo: false,
overlay: {
warnings: true,
errors: true,
},
// 注释掉的地方是前端配置代理访问后端的示例
// proxy: {
// [baseURL]: {
// target: `http://你的后端接口地址`,
// ws: true,
// changeOrigin: true,
// pathRewrite: {
// ["^/" + baseURL]: "",
// },
// },
// },
after: mockServer(),
},
configureWebpack() {
return {
resolve: {
alias: {
'@': resolve('src'),
'*': resolve(''),
},
},
plugins: [
new Webpack.ProvidePlugin(providePlugin),
new WebpackBar({
name: webpackBarName,
}),
],
}
},
chainWebpack(config) {
config.resolve.symlinks(true)
config.module.rule('svg').exclude.add(resolve('src/icon/remixIcon')).end()
config.module
.rule('remixIcon')
.test(/\.svg$/)
.include.add(resolve('src/icon/remixIcon'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({ symbolId: 'remix-icon-[name]' })
.end()
config.when(process.env.NODE_ENV === 'development', (config) => {
config.devtool('source-map')
})
config.when(process.env.NODE_ENV !== 'development', (config) => {
config.performance.set('hints', false)
config.devtool('none')
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'vue-admin-beautiful-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial',
},
},
})
config
.plugin('banner')
.use(Webpack.BannerPlugin, [`${webpackBanner}${time}`])
.end()
config.module
.rule('images')
.use('image-webpack-loader')
.loader('image-webpack-loader')
.options({
bypassOnDebug: true,
})
.end()
})
if (build7z) {
config.when(process.env.NODE_ENV === 'production', (config) => {
config
.plugin('fileManager')
.use(FileManagerPlugin, [
{
onEnd: {
delete: [`./${outputDir}/video`, `./${outputDir}/data`],
archive: [
{
source: `./${outputDir}`,
destination: `./${outputDir}/${abbreviation}_${outputDir}_${date}.7z`,
},
],
},
},
])
.end()
})
}
},
runtimeCompiler: true,
productionSourceMap: false,
css: {
requireModuleExtension: true,
sourceMap: true,
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true,
modifyVars: {
'vab-color-blue': '#1890ff',
'vab-margin': '20px',
'vab-padding': '20px',
'vab-header-height': '65px',
},
},
},
},
},
}