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
| const path = require("path");
| const {
| publicPath,
| assetsDir,
| outputDir,
| lintOnSave,
| transpileDependencies,
| title,
| abbreviation,
| devPort,
| providePlugin,
| build7z,
| donation,
| } = require("./src/config");
|
| const { version, author } = require("./package.json");
|
| const Webpack = require("webpack");
| const WebpackBar = require("webpackbar");
| 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 = "vue-intergrate";
| process.env.VUE_APP_AUTHOR = "basic";
| process.env.VUE_APP_UPDATE_TIME = time;
| process.env.VUE_APP_VERSION = version;
|
| const resolve = (dir) => path.join(__dirname, dir);
|
| module.exports = {
| publicPath,
| assetsDir,
| outputDir,
| lintOnSave,
|
| transpileDependencies,
| devServer: {
| hot: true,
| port: devPort,
| open: true,
| noInfo: false,
| overlay: {
| warnings: true,
| errors: true,
| },
| },
| configureWebpack() {
| return {
| resolve: {
| alias: {
| "@": resolve("src"),
| },
| },
| plugins: [
| new Webpack.ProvidePlugin(providePlugin),
| new WebpackBar({
| name: "vue-intergrate",
| }),
| ],
| };
| },
| chainWebpack(config) {
| config.plugins.delete("preload");
| config.plugins.delete("prefetch");
| config.module
| .rule("svg")
| .exclude.add(resolve("src/remixIcon"))
| .add(resolve("src/colorfulIcon"))
| .end();
|
| config.module
| .rule("remixIcon")
| .test(/\.svg$/)
| .include.add(resolve("src/remixIcon"))
| .end()
| .use("svg-sprite-loader")
| .loader("svg-sprite-loader")
| .options({ symbolId: "remix-icon-[name]" })
| .end();
|
| config.module
| .rule("colorfulIcon")
| .test(/\.svg$/)
| .include.add(resolve("src/colorfulIcon"))
| .end()
| .use("svg-sprite-loader")
| .loader("svg-sprite-loader")
| .options({ symbolId: "colorful-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({
| automaticNameDelimiter: "-",
| chunks: "all",
| cacheGroups: {
| chunk: {
| name: "vab-chunk",
| test: /[\\/]node_modules[\\/]/,
| minSize: 131072,
| maxSize: 524288,
| chunks: "async",
| minChunks: 2,
| priority: 10,
| },
| vue: {
| name: "vue",
| test: /[\\/]node_modules[\\/](vue(.*)|core-js)[\\/]/,
| chunks: "initial",
| priority: 20,
| },
| elementUI: {
| name: "element-ui",
| test: /[\\/]node_modules[\\/]element-ui(.*)[\\/]/,
| priority: 30,
| },
| extra: {
| name: "vab-layouts",
| test: resolve("src/layouts"),
| priority: 40,
| },
| },
| });
| });
| },
| runtimeCompiler: true,
| productionSourceMap: false,
| css: {
| requireModuleExtension: true,
| sourceMap: true,
| loaderOptions: {
| scss: {
| /*sass-loader 8.0语法 */
| //prependData: '@import "~@/styles/variables.scss";',
|
| /*sass-loader 9.0写法,感谢github用户 shaonialife*/
| additionalData(content, loaderContext) {
| const { resourcePath, rootContext } = loaderContext;
| const relativePath = path.relative(rootContext, resourcePath);
| if (
| relativePath.replace(/\\/g, "/") !== "src/styles/variables.scss"
| ) {
| return '@import "~@/styles/variables.scss";' + content;
| }
| return content;
| },
| },
| },
| },
| };
|
|