-
Notifications
You must be signed in to change notification settings - Fork 10
/
vue.config.js
92 lines (91 loc) · 2.44 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
const path = require("path");
const CompressionPlugin = require("compression-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const Webpack = require("webpack");
const pkg = require("./package.json");
const webpackBanner = `project: vue-amis-sdk@${pkg.version} \n github https://github.com/h7ml/vue-amis-sdk \n author: h7ml([email protected]) \n Time: `;
const dateTime = new Date();
process.env.VUE_APP_VERSION = pkg.version
function resolve(dir) {
return path.join(__dirname, "..", dir);
}
module.exports = {
devServer: {
// development server port 8000
port: 3000,
// If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
proxy: {
"/amis": {
target: "https://aisuda.bce.baidu.com/",
changeOrigin: true,
},
"/api": {
target: "https://preview.pro.antdv.com/",
changeOrigin: true,
},
},
},
productionSourceMap: false,
pages: {
index: {
entry: "examples/main.js",
template: "public/index.html",
filename: "index.html",
},
},
configureWebpack: {
plugins: [],
},
chainWebpack: (config) => {
if (process.env.BUILD_TARGET === "lib") {
config.plugin("compressionPlugin").use(
new CompressionPlugin({
algorithm: "gzip", //开启gzip
test: /\.js$|\.html$|\.css/, // 匹配文件名
threshold: 2048, // 对超过10k的数据压缩
deleteOriginalAssets: false, // 不删除源文件
})
);
config
.plugin("banner")
.use(Webpack.BannerPlugin, [`${webpackBanner}${dateTime}`]);
config.plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
drop_debugger: true, // 注释console
drop_console: true,
pure_funcs: ["console.log"], // 移除console
},
},
sourceMap: false,
parallel: true,
})
);
config.devtool = false;
config.externals = {
vue: "Vue",
axios: "axios",
amis: "amis",
"element-ui": "ELEMENT",
};
}
config.module
.rule("js")
.include.add(resolve("packages"))
.end()
.use("bable")
.loader("bable-loader")
.tap((options) => {
return options;
});
},
css: {
loaderOptions: {
sass: {
implementation: require("sass"),
},
},
},
};