Skip to content

Commit 3c71166

Browse files
committed
更新 vue vite.config.js 解决 react-virtualized 的问题
1 parent 514c624 commit 3c71166

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

vue/vite.config.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,32 @@ import { fileURLToPath, URL } from "node:url";
33
import { defineConfig } from "vite";
44
import vue from "@vitejs/plugin-vue";
55
import vueJsx from "@vitejs/plugin-vue-jsx";
6+
import * as path from 'path';
7+
import * as fs from 'fs';
8+
9+
// 解决 react-virtualized 的一个历史遗留问题,参考 issue:https://github.com/bvaughn/react-virtualized/issues/1722
10+
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
11+
12+
function reactVirtualized() {
13+
return {
14+
name: 'my:react-virtualized',
15+
configResolved() {
16+
const file = require
17+
.resolve('react-virtualized')
18+
.replace(
19+
path.join('dist', 'commonjs', 'index.js'),
20+
path.join('dist', 'es', 'WindowScroller', 'utils', 'onScroll.js')
21+
);
22+
const code = fs.readFileSync(file, 'utf-8');
23+
const modified = code.replace(WRONG_CODE, '');
24+
fs.writeFileSync(file, modified);
25+
},
26+
};
27+
}
628

729
// https://vitejs.dev/config/
830
export default defineConfig({
9-
plugins: [vue(), vueJsx()],
31+
plugins: [vue(), vueJsx(), reactVirtualized()],
1032
resolve: {
1133
alias: {
1234
"@": fileURLToPath(new URL("./src", import.meta.url)),

0 commit comments

Comments
 (0)