-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
61 lines (59 loc) · 1.63 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
52
53
54
55
56
57
58
59
60
61
import purgecss from "@fullhuman/postcss-purgecss";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import autoprefixer from "autoprefixer";
import { readFile } from "fs/promises";
import tailwindcss from "tailwindcss";
import { defineConfig } from "vite";
import { resolve } from "./require.ts";
import config from "./tailwind.config.ts";
const hash = await new Promise<string>((r) => {
// Read the hash from ./hash.txt
readFile(resolve(__dirname, "./hash.txt"), "utf-8")
.then((hash) => r(hash.trim()))
.catch(() => r(""));
});
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
svelte({ compilerOptions: { modernAst: true } }),
// @ts-ignore
purgecss({}),
],
css: {
postcss: {
plugins: [tailwindcss({ config }), autoprefixer()],
},
},
resolve: {
alias: {
"@": resolve(__dirname, "./"),
},
},
// mode: "development",
build: {
// minify: false,
rollupOptions: {
maxParallelFileOps: 128,
output: {
entryFileNames: `assets/[name]-${hash}.js`,
chunkFileNames: `assets/[name]-${hash}.js`,
assetFileNames: `assets/[name]-${hash}.[ext]`,
manualChunks(id) {
if (id.includes("index") || id.includes("index-client")) {
return "index";
}
if (
(id.includes("node_modules") &&
id.includes("svelte") &&
(id.includes("internal") ||
id.includes("store") ||
id.includes("transition"))) ||
id.includes("index-client")
) {
return "index";
}
},
},
},
},
});