# 按需加载组件

使用 babel-plugin-import 插件实现 git 项目地址 (opens new window)

在项目 babel.config.js 里面配置:

module.exports = {
  plugins: [
    ["import", { libraryName: "antd", style: true }],
    [
      "import",
      {
        // 导入一个插件
        libraryName: "arctic-business-component", // 暴露的库名
        camel2DashComponentName: false, // 关闭驼峰转换
        customName: (name) => {
          return `arctic-business-component/lib/${name}`; // 核心配置 根据你自己的组件目录配置
        },
        style: (name) => `arctic-business-component/lib/${name}/index.css`, // 转换后的路径
      },
      "arctic-business-component",
    ],
  ],
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 使用组件按需加载地址 (opens new window)

# antd 业务组件 (opens new window)

Last Updated: 9/1/2021, 2:33:08 PM