Skip to content

Commit

Permalink
Merge pull request #29 from 1eeing/main
Browse files Browse the repository at this point in the history
更新 vue vite.config.js 解决 react-virtualized 的问题
  • Loading branch information
chandarlee authored Jul 23, 2024
2 parents 514c624 + 3c71166 commit ee31364
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,32 @@ import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import * as path from 'path';
import * as fs from 'fs';

// 解决 react-virtualized 的一个历史遗留问题,参考 issue:https://github.com/bvaughn/react-virtualized/issues/1722
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;

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(WRONG_CODE, '');
fs.writeFileSync(file, modified);
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [vue(), vueJsx(), reactVirtualized()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down

0 comments on commit ee31364

Please sign in to comment.