-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
47 lines (44 loc) · 1.72 KB
/
Copy pathvite.config.ts
File metadata and controls
47 lines (44 loc) · 1.72 KB
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
import solid from 'solid-start/vite'
import staticAdapter from "solid-start-static"
import {defineConfig} from 'vite'
import {resolve} from "path";
export default defineConfig(() => {
return {
base: "/anique",
plugins: [
{
name: "examples",
enforce: "pre",
transform(code, id) {
if (id.includes("Example") && id.endsWith(".tsx")) {
const exportDefaultRegex = /export\s+default\s+function\s+(\w+)/;
const matches = exportDefaultRegex.exec(code);
if (exportDefaultRegex && matches) {
const [, functionName] = matches;
const originalCode = code
.split(/\r?\n/)
.filter((line) => !line.trim().startsWith("// eslint-disable"))
.join("\n");
code = code.replace(/export\s+default\s+function/, "function");
code += `\n${functionName}.code = ${JSON.stringify(
originalCode
)};\n`;
code += `\nexport default ${functionName}`;
return code;
}
}
},
},
solid({
adapter: staticAdapter(),
ssr: true
})
],
resolve: {
alias: {
"@qinetik/emotion": resolve(__dirname, "./packages/styled/src"),
"@qinetik/anique": resolve(__dirname, "./packages/anique/src")
}
}
}
})