# 动态导入组件语法替换

aComp(resolve){ require(['xx.vue'], resolve) } 转为 aComp: () => import('xx.vue')

# 如何使用

安装

pnpm add @plugin-light/vite-plugin-replace-require-dynamic -D

vite.config.ts 中添加如下设置:

import { defineConfig } from 'vite';
import { replaceRequireDynamicVitePlugin } from '@plugin-light/vite-plugin-replace-require-dynamic';


export default defineConfig({
  plugins: [
    replaceRequireDynamicVitePlugin(),
  ],
});
Last Updated: 2024/10/12 08:54:40