-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
52 lines (50 loc) · 1.17 KB
/
vite.config.ts
File metadata and controls
52 lines (50 loc) · 1.17 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
48
49
50
51
52
/*!
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { defineConfig } from "vite";
import { transformSVG } from "./transformsvg";
export default defineConfig({
define: {
"process.env.PKG_VERSION": JSON.stringify("local"),
},
resolve: {
alias: {
abledom: "/src",
},
},
server: {
port: 5173,
},
build: {
rollupOptions: {},
},
plugins: [
{
name: "postprocess-raw",
enforce: "post",
transform(code, id) {
if (id.endsWith(".svg?raw")) {
// Your postprocessing logic here
// const processed = code.replace(/body/g, 'html body'); // Example
return {
code: `import {DOMBuilder} from "./domBuilder"; export default ${transformSVG(code)};`,
map: null,
};
}
return undefined;
},
},
{
name: "custom-index-html",
configureServer(server) {
server.middlewares.use((req, _, next) => {
if (req.url === "/" || req.url === "/index.html") {
req.url = "/tests/pages/index.html";
}
next();
});
},
},
],
});