-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathvue.config.js
119 lines (118 loc) · 3.16 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
const AutoImportsPlugin = require("./webpack/lib/auto-imports-plugin.js");
const CustomImportsPlugin = require("./webpack/lib/custom-imports-plugin.js");
const CompressionPlugin = require("compression-webpack-plugin");
const fs = require("fs"), path = require("path");
const { EnvironmentPlugin, ProvidePlugin } = require("webpack");
const EventHooksPlugin = require("event-hooks-webpack-plugin");
const ZipPlugin = require("zip-webpack-plugin");
module.exports = {
configureWebpack: {
devtool: "source-map",
optimization: {
chunkIds: "named",
concatenateModules: false,
flagIncludedChunks: false,
mergeDuplicateChunks: false,
moduleIds: "named",
removeAvailableModules: false,
splitChunks: {
cacheGroups: {
babylon: {
test: /babylonjs/,
name: "babylon",
chunks: "all"
},
monacoEditor: {
test: /[\\/]node_modules[\\/]monaco-editor/,
name: "monaco-editor",
chunks: "all"
}
}
},
usedExports: false
},
performance: {
hints: false
},
plugins: [
new AutoImportsPlugin(),
new EnvironmentPlugin({
"BUILD_DATETIME": (new Date()).toString()
}),
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
...((process.env.NODE_ENV === "production") ? [
new CustomImportsPlugin(),
new EventHooksPlugin({
beforeCompile() {
const apiDocs = path.resolve(__dirname, "./DuetAPI.xml")
if (fs.existsSync(apiDocs)) {
fs.copyFileSync(apiDocs, path.resolve(__dirname, "./public/DuetAPI.xml"));
} else {
const dsfApiDocs = path.resolve(__dirname, "../DuetSoftwareFramework/src/DuetAPI/DuetAPI.xml");
if (fs.existsSync(dsfApiDocs)) {
fs.copyFileSync(dsfApiDocs, path.resolve(__dirname, "./public/DuetAPI.xml"));
}
}
},
afterEmit() {
const apiDocs = path.resolve(__dirname, "./public/DuetAPI.xml");
if(fs.existsSync(apiDocs)) {
fs.unlinkSync(apiDocs);
}
}
}),
new CompressionPlugin({
exclude: /\.zip$/,
minRatio: Infinity
}),
...((process.env.NOZIP) ? [] : [
new ZipPlugin({
filename: "DuetWebControl-SD.zip",
include: [/\.gz$/, /\.woff$/, /\.woff2$/],
exclude: ["robots.txt"]
}),
new ZipPlugin({
filename: "DuetWebControl-SBC.zip",
exclude: [/\.gz$/, /\.zip$/]
})
])
] : [])
],
resolve: {
extensions: [".ts", ".js"]
}
},
chainWebpack: config => {
config.optimization.minimizer("terser").tap(args => {
const { terserOptions } = args[0];
terserOptions.keep_classnames = true;
terserOptions.keep_fnames = true;
return args;
});
config.optimization.set("splitChunks", {
chunks: "all",
cacheGroups: {
defaultVendors: false,
default: false
}
});
config.plugins.delete("prefetch");
config.plugins.delete("hash-module-ids");
},
pwa: {
name: "Duet Web Control",
themeColor: "#2196f3",
appleMobileWebAppCapable: "yes",
appleMobileWebAppStatusBarStyle: "black",
workboxOptions: {
maximumFileSizeToCacheInBytes: 20000000 // 20MB
}
},
transpileDependencies: [
"vuetify"
]
}