-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
119 lines (109 loc) · 3.32 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
114
115
116
117
118
119
/* eslint-env node */
const fs = require("fs");
const ExtraWatchWebpackPlugin = require("extra-watch-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
module.exports = {
lintOnSave: "default",
productionSourceMap: false,
css: {
extract: false,
},
devServer: {
host: "0.0.0.0",
port: 8080,
bonjour: true,
disableHostCheck: true,
},
chainWebpack(config) {
if (process.env.BUILD_MODE === "targz") {
config
.entry("app")
.clear()
.add("./src/targz-entry.js");
}
config.plugins.delete("preload");
config.plugins.delete("prefetch");
config.plugin("extra-watch").use(ExtraWatchWebpackPlugin, [
{
dirs: ["src/lang/"],
},
]);
config.plugin("bundle-analyzer").use(BundleAnalyzerPlugin, [
{
analyzerMode: "static",
openAnalyzer: false, // process.env.NODE_ENV === "production",
generateStatsFile: false,
},
]);
config.module
.rule("images")
.use("url-loader")
.tap((options) => {
options.limit = undefined;
return options;
});
config.module
.rule("text")
.test(/\.txt$/i)
.use("raw-loader")
.loader("raw-loader");
config.module
.rule("worker")
.test(/\.worker\.js$/i)
.use("worker-loader")
.loader("worker-loader")
.tap((options) => {
options = options || {};
options.inline = "no-fallback";
return options;
})
.end()
.use("babel-loader")
.loader("babel-loader");
config.module.rule("js").exclude.add(/\.worker\.js/);
if (config.plugins.has("copy")) {
config.plugin("copy").tap((args) => {
const options = args[0][0] || {};
options.ignore = options.ignore || [];
options.ignore.push("favicon.png");
return args;
});
}
if (fs.existsSync("./remoteConsoleUrl.local")) {
config.plugin("html").tap((args) => {
const options = (args[0] = args[0] || {});
options.REMOTE_CONSOLE_SCRIPT = fs
.readFileSync("./src/remoteConsole.js", "utf-8")
.replace(
/\bREMOTE_CONSOLE_URL\b/g,
fs.readFileSync("./remoteConsoleUrl.local", "utf-8").trim(),
);
return args;
});
}
if (process.env.NODE_ENV === "production") {
config.plugin("html").tap((args) => {
const options = (args[0] = args[0] || {});
options.inject = false;
options.minify = options.minify || {};
options.minify.collapseWhitespace = false;
options.minify.removeComments = false;
if (process.env.BUILD_MODE === "targz") {
options.filename = "targz.html";
}
options.BUILD_MODE = process.env.BUILD_MODE;
return args;
});
config.resolve.alias
.set("bootstrap.css$", "bootstrap/dist/css/bootstrap.min.css")
.set("bootstrap.reboot$", "bootstrap/dist/css/bootstrap-reboot.min.css")
.set("bootstrap.js$", "bootstrap/dist/js/bootstrap.bundle.min.js");
} else {
config.resolve.alias
.set("bootstrap.css$", "bootstrap/dist/css/bootstrap.css")
.set("bootstrap.reboot$", "bootstrap/dist/css/bootstrap-reboot.css")
.set("bootstrap.js$", "bootstrap/dist/js/bootstrap.bundle.js");
}
},
};