-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (51 loc) · 1.48 KB
/
vite.config.ts
File metadata and controls
53 lines (51 loc) · 1.48 KB
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
import { defineConfig } from "vite";
import solid from "vite-plugin-solid";
import { createHtmlPlugin } from "vite-plugin-html";
export default defineConfig(({ command, mode }) => {
const timestamp = new Date().getTime();
console.log(mode);
return {
plugins: [
solid(),
createHtmlPlugin({
minify: true
})
],
cacheControl: "max-age=3600",
css: {
modules: {
localsConvention: "camelCase",
generateScopedName: "[local]_[hash:base64:5]"
}
},
build: {
// minify: "esbuild",
emptyOutDir: true,
outDir: "build",
sourcemap: false,
minify: mode === "production",
cssCodeSplit: true,
modulePreload: true,
chunkSizeWarningLimit: 1000000,
cacheControl: "max-age=3600",
rollupOptions: {
output: {
chunkFileNames: `assets/js/[hash]-${timestamp}.js`,
entryFileNames: `assets/js/[hash]-${timestamp}.js`,
assetFileNames: ({ name }) => {
if (/\.(gif|jpe?g|png|svg|webp|avif)$/.test(name ?? "")) {
return `assets/images/[hash]-${timestamp}[extname]`;
}
if (/\.(ttf|woff2|svg)$/.test(name ?? "")) {
return `assets/font/[hash]-${timestamp}[extname]`;
}
if (/\.css$/.test(name ?? "")) {
return `assets/css/[hash]-${timestamp}[extname]`;
}
return `assets/[hash]-${timestamp}[extname]`;
}
}
}
}
};
});