使用 nuxt 构建配置后,babel-import-plugin 似乎没有减少 ant-design-vue 的大小

问题描述

根据文档 Docs 建议使用模块化的 antd 以确保优化并减小应用程序大小。但是,我尝试在我的 nuxt 构建配置中使用确切的代码,但应用程序大小在使用 yarn build

构建之前和之后保持不变

下面是我的nuxt构建配置和构建前后的截图

 build: {
    analyze: true,// Remove this mode before deployment
    babel: {
      plugins: [
        [
          "import",{
            libraryName: "ant-design-vue",libraryDirectory: "es",style: "css"
          },]
      ]
    }
  }

这是添加babel-import-plugin前后的构建

enter image description here

解决方法

我刚刚解决了这个问题,并通过仅从 nuxt 配置中删除了 ant-design 插件来大幅减小尺寸。

最初我的插头看起来像这样

 plugins: [
    "@/plugins/antd-ui",{ src: "@/plugins/vue-carousel",ssr: false }
    // "@/plugins/axios"
  ],

然后我删除了插件以获得这样的东西

 plugins: [
    { src: "@/plugins/vue-carousel",

现在我有这个最小尺寸 enter image description here