/
vue.config.js
59 lines (55 loc) · 1.61 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
const webpack = require('webpack');
// const CompressionWebpackPlugin = require("compression-webpack-plugin");
// const productionGzipExtensions = ["js", "css"];
// const isProduction = process.env.NODE_ENV === "production";
// const AutoImport = require('unplugin-auto-import/webpack');
const Components = require('unplugin-vue-components/webpack');
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers');
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = {
publicPath: '/',
configureWebpack: config => {
// element-plus import es-module
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
});
// if (isProduction) {
// config.plugins.push(
// new CompressionWebpackPlugin({
// algorithm: "gzip",
// test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
// threshold: 10240,
// minRatio: 0.8
// })
// );
// }
config.plugins.push(
new webpack.DefinePlugin({
//定义全局变量
'process.env': {
BUILD_ENV: JSON.stringify(process.env.BUILD_ENV)
}
})
);
// element-plus按需引入
/*config.plugins.push(
AutoImport({
resolvers: [ElementPlusResolver()]
})
);*/
config.plugins.push(
Components({
resolvers: [ElementPlusResolver()]
})
);
// config.plugins.push(new BundleAnalyzerPlugin());
},
devServer: {
port: 8121,
host: '0.0.0.0',
https: false,
open: true
}
};