-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
113 lines (105 loc) · 3.26 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
const webpack = require("webpack");
const path = require("path");
const meta = require("./src/info/meta");
const ImageminWebpWebpackPlugin = require("imagemin-webp-webpack-plugin-2");
function resolve(dir) {
return path.join(__dirname, ".", dir);
}
module.exports = {
css: {
loaderOptions: {
sass: {
additionalData: `
@import "@/assets/style/function.scss";
`,
},
},
},
configureWebpack: {
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
// optimization: {
// splitChunks: {
// minSize: 10000,
// maxSize: 20000
// }
// }
},
devServer: {
port: 9000, // CHANGE YOUR PORT HERE!
https: false,
},
chainWebpack: (config) => {
//config.module.rules.delete('svg') // 重点:删除默认配置中处理svg,
// const svgRule = config.module.rule('svg')
// svgRule.uses.clear()
const svgRule = config.module.rule("svg");
svgRule.uses.clear();
config.module
.rule("svg")
.oneOf("inline-svg")
.resourceQuery(/inline/)
.use("babel")
.loader("babel-loader")
.end()
.use("vue-svg-loader")
.loader("vue-svg-loader")
.end()
.end()
.oneOf("file")
.use("file-loader")
.loader("file-loader")
.end()
.end();
config.module
.rule("@yzfe/vue-svgicon-loader")
.test(/\.svg$/)
.include.add(resolve("src/assets/svg")) // 处理svg目录
.end()
.use("@yzfe/vue-svgicon-loader")
.loader("@yzfe/vue-svgicon-loader")
.options({
symbolId: "icon-[name]",
});
config.plugin("html").tap((args) => {
args[0].title = meta.info.title;
args[0].metaTitle = meta.info.title;
args[0].ogMetaTitle = meta.info.title;
args[0].metaDescription = meta.info.description;
args[0].ogMetaDescription = meta.info.description;
args[0].metaKeywords = meta.info.keywords;
args[0].ogMetaType = "website";
return args;
});
// config.plugin("preload").tap((options) => {
// // for import() lazy routes use initial https://github.com/vuejs/preload-webpack-plugin
// options.include = "initial";
// // or split chunks at the bottom
// options.include = ["chunk-elementUI"];
// return options;
// });
// remove the prefetch plugin
config.plugins.delete("prefetch");
},
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"windows.jQuery": "jquery",
}),
new ImageminWebpWebpackPlugin({
config: [{
test: /\.(jpe?g|png)/,
options: {
quality: 75,
},
}, ],
overrideExtension: false,
}),
],
},
};