# 异步组件转换

使用语法糖 /* @async */ 包裹 vue 组件引用,会自动转换为 defineAsyncComponent 异步组件。

# 如何使用

安装

pnpm add @plugin-light/vite-plugin-transform-async-component -D

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

import { defineConfig } from 'vite';
import { transformAsyncComponentsPlugin } from '@plugin-light/vite-plugin-transform-async-component';

export default defineConfig({
  plugins: [
    transformAsyncComponentsPlugin(),
  ],
});

# 示例

<script>
/* @async */
import ComponentA from './index-a.vue';
import ComponentB from './index-b.vue';
/* @endasync */
</script>
Last Updated: 2025/3/29 16:32:34