-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.ts
51 lines (49 loc) · 1.51 KB
/
vite.config.ts
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
import { defineConfig } from "vite";
import path from "path";
import vue from "@vitejs/plugin-vue";
import glsl from "vite-plugin-glsl";
// https://vitejs.dev/config/
export default defineConfig({
// base: "",
// publicDir: "./public",
assetsInclude: ["**/*.glb", "**/*.hdr", "**/*.mp3", "**/*.ico", "**/*.svg"],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
// "@static": path.resolve(__dirname, "static"),
"@assets": path.resolve(__dirname, "src/assets"),
"@shaders": path.resolve(__dirname, "src/shaders"),
"@utils": path.resolve(__dirname, "src/utils"),
"@components": path.resolve(__dirname, "src/components"),
},
},
build: {
rollupOptions: {
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
},
output: {
assetFileNames: (assetInfo: any) => {
if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)$/.test(assetInfo.name)) {
return `media/[name].[hash][ext]`;
}
// else if (/\.(glb|hdr)$/.test(assetInfo.name)) { // 匹配资源文件后缀 可以自定义存放位置
return `assets/[name]-[hash].[ext]`; // 不匹配的资源文件存放至assets,以[name]-[hash].[ext]命名规则,注意两处的命名规则不同
},
},
},
},
plugins: [
vue(),
glsl({
compress: true,
watch: true,
}),
],
});