-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
34 lines (32 loc) · 1.02 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import fs from "fs";
import path from "path";
import { createRequire } from "node:module";
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
export function reactVirtualized() {
return {
name: "my:react-virtualized",
configResolved() {
const require = createRequire(import.meta.url);
const file = require
.resolve("react-virtualized")
.replace(
path.join("dist", "commonjs", "index.js"),
path.join("dist", "es", "WindowScroller", "utils", "onScroll.js"),
);
const code = fs.readFileSync(file, "utf-8");
const modified = code.replace(WRONG_CODE, "");
fs.writeFileSync(file, modified);
},
};
}
// https://vitejs.dev/config/
export default defineConfig({
base: "/local/dashboard/",
server: {
port: 1234,
},
plugins: [react(), reactVirtualized(), tsconfigPaths()],
});