-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
51 lines (47 loc) · 1.39 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const path = require('path');
// const CompressionPlugin = require('compression-webpack-plugin');
// function resolve(dir) {
// return path.join(__dirname, './', dir);
// }
// const { openGzip } = require('./package.json');
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
outputDir: 'dist',
lintOnSave: true,
productionSourceMap: false,
css: {
loaderOptions: {
scss: {
prependData: `
@import "@/styles/variables.scss";
@import "@/styles/mixin.scss";
`,
},
},
},
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.mode = 'production';
} else {
// 为开发环境修改配置...
config.mode = 'development';
config.devtool = 'source-map'; // 开发环境显示源码,方便调试
}
},
chainWebpack: (config) => {
config.plugin('preload').tap(() => [
{
rel: 'preload',
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: 'initial',
},
]);
// 修复HMR(热更新)失效
config.resolve.symlinks(true);
// 移除prefetch插件
config.plugins.delete('prefetch');
},
};