-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.js
42 lines (40 loc) · 1.14 KB
/
vite.config.js
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import fs from "fs";
import path from "path";
/**
* A function that configures a react-virtualized plugin to fix a build error with react-virtualized.
* see https://github.com/bvaughn/react-virtualized/issues/1722
* @returns {Object} The configuration object for react-virtualized.
*/
function reactVirtualized() {
return {
name: "my:react-virtualized",
configResolved() {
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(
`import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`,
""
);
fs.writeFileSync(file, modified);
},
};
}
export default defineConfig({
build: {
outDir: "build",
commonjsOptions: { transformMixedEsModules: true },
},
base: "/",
plugins: [reactVirtualized(), react()],
server: {
open: true,
port: 3000,
},
});