-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
55 lines (50 loc) · 1.35 KB
/
vite.config.mts
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
import fs from "fs";
import path from "path";
import mdx from "@mdx-js/rollup";
import remarkGfm from "remark-gfm";
import { PluginOption } from "vite";
import react from "@vitejs/plugin-react";
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
const OUT_DIR = "./dist";
/**
* copy maps assets to dist folder
*/
const copyMapsAssets = (): PluginOption => {
return {
name: "copy-maps-assets",
apply: "build",
writeBundle() {
const maps = path.resolve(__dirname, "./maps");
const dist = path.resolve(__dirname, OUT_DIR);
["glyphs", "styles", "sprites"].forEach((dir) =>
fs.cpSync(path.join(maps, dir), path.join(dist, dir), {
recursive: true,
force: true,
})
);
},
};
};
export default defineWorkersConfig({
build: { outDir: OUT_DIR },
plugins: [
react(),
copyMapsAssets(),
TanStackRouterVite({ generatedRouteTree: "./src/route-tree-gen.ts" }),
mdx({ remarkPlugins: [remarkGfm] }),
] as never,
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@tabler/icons-react": "@tabler/icons-react/dist/esm/icons/index.mjs",
},
},
test: {
poolOptions: {
workers: {
wrangler: { configPath: "./wrangler.toml" },
},
},
},
});