-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
107 lines (105 loc) · 3.09 KB
/
vite.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
import { fileURLToPath, URL } from "url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import viteCompression from "vite-plugin-compression";
import dns from "dns";
import zlib from "zlib";
// Localhost instead of ip 127.0.0.1
dns.setDefaultResultOrder("verbatim");
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
//Workaround for building environments
let dist = null;
// mode === "pre" ? "build/pre/" : "build/dev/";
if (mode === "development") {
dist = "build/dev/";
} else if (mode === "pre") {
dist = "build/pre/";
} else if (mode === "prod") {
dist = "build/prod/";
}
return {
plugins: [
vue(),
viteCompression({
filter: new RegExp("\\.(js|json|css|html|svg)$", "i"),
threshold: 10240,
algorithm: "brotliCompress",
ext: ".br",
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]:
zlib.constants.BROTLI_MAX_QUALITY,
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
},
},
deleteOriginFile: false,
}),
viteCompression({
filter: new RegExp("\\.(js|json|css|html)$", "i"),
threshold: 10240,
algorithm: "gzip",
ext: ".gz",
compressionOptions: {
level: zlib.constants.Z_BEST_COMPRESSION,
},
deleteOriginFile: false,
}),
],
define: {
__APP_VERSION__: JSON.stringify(require("./package.json").version),
// Can be set to true if no options api components are used. The build will be lighter
__VUE_OPTIONS_API__: "true",
// Enables devtools in production env, can be set to true for debugging purposes
__VUE_PROD_DEVTOOLS__: "false",
// Gives more details about hydration mismatch errors, not needed unless we are using SSR
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
"~": fileURLToPath(new URL("src", import.meta.url)),
//Example alias bulma sass
// bulma: "bulma/bulma.sass",
},
},
server: {
port: 8080,
// Exits if port is already in use
strictPort: true,
// Uncomment for LOCAL DEVELOPMENT only to be able to use https with certificate in localhost.
// Https configuration, default is false
// https: {
// key: fs.readFileSync("./certificate/localhost-key.pem"),
// cert: fs.readFileSync("./certificate/localhost.pem"),
// },
},
preview: {
port: 8081,
strictPort: true,
https: false,
},
build: {
outDir: dist,
reportCompressedSize: false,
},
css: {
preprocessorOptions: {
scss: {
additionalData: "@use '@/styles/variables' as app-variables;",
},
},
modules: {
scopeBehaviour: "global",
},
},
test: {
include: ["__tests__/**/*.test.js"],
environment: "jsdom",
globals: true,
deps: {
inline: ["@vue"],
},
},
};
});