-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
59 lines (53 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
52
53
54
55
56
57
58
59
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import fs from "node:fs/promises";
export default defineConfig({
server: {
port: 6007,
},
build: {
target: "es2022",
sourcemap: true,
},
base: "/hedwig-design-system/examples/",
plugins: [
remix({
ssr: false,
basename: "/hedwig-design-system/examples/",
ignoredRouteFiles: ["*/**.css"],
/**
* Read the app/examples folder and create routes for each example component.
*/
async routes(defineRoutes) {
const examplesFolder = "./app/examples";
const exampleFilesAndDirs = await fs.readdir(new URL(examplesFolder, import.meta.url), {
recursive: true,
});
const componentExamples = exampleFilesAndDirs.filter((path) => path.endsWith(".tsx"));
const routes = defineRoutes((route) => {
for (const example of componentExamples) {
const urlPath = example.replace(/\.tsx$/, "");
const filePath = "examples/" + example;
route(urlPath, filePath);
}
});
return routes;
},
future: {
v3_singleFetch: true,
v3_lazyRouteDiscovery: true,
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
},
}),
],
resolve: {
alias: [
{
find: "@postenbring/hedwig-react",
replacement: new URL("../../packages/react/src", import.meta.url).pathname,
},
],
},
});