forked from LIlGG/halo-theme-sakura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
45 lines (43 loc) · 1.29 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
import { globSync } from "glob";
import { defineConfig } from "vite";
import { fileURLToPath } from "url";
import path from "path";
import PurgeIcons from 'vite-plugin-purge-icons';
const THEME_BASE = "/themes/theme-sakura";
const ASSETS_BASE = `/assets/dist/`;
export default ({ mode }: { mode: string }) => {
return defineConfig({
plugins: [
PurgeIcons({
content: [
'./templates/*/*.html',
],
})
],
base: THEME_BASE + ASSETS_BASE,
build: {
outDir: "templates" + ASSETS_BASE,
minify: mode === 'development' ? false : true,
rollupOptions: {
input: Object.fromEntries(
globSync(["src/main.ts", "src/libs/**/*.*", "src/page/**/*.*"]).map((file) => [
path.relative("src", file.slice(0, file.length - path.extname(file).length)),
fileURLToPath(new URL(file, import.meta.url)),
])
),
output: {
format: "es",
entryFileNames: "[name].min.js",
assetFileNames: (assetInfo) => {
if (assetInfo.name && assetInfo.name.endsWith(".css")) {
return "css/[name].min.[ext]";
}
return "[name].min.[ext]";
},
},
},
sourcemap: false,
chunkSizeWarningLimit: 1024
},
});
};