首页 > Web开发 > 详细

webpack antd 按需加载

时间:2019-12-29 23:49:55      阅读:154      评论:0      收藏:0      [点我收藏+]

安装babel-plugin-import插件。下面方法二选一,都可以实现antd的按需加载

一、配置webpack.config.js文件

{
    test: /.jsx?$/,
    exclude: /(node_modules|bower_components)/,
    use: [{
        loader: ‘babel-loader‘
    }],
    options: {
        "plugins": [
            [
                "import", {
                    "libraryName": "antd",
                    "style": true
                }
            ]
        ]
    }
}

二、配置babelrc文件

{
  "presets": ["env", "react"],
  "plugins": [
    "transform-runtime",
    "transform-object-rest-spread",
    [
      "import", {
        "libraryName": "antd",
        "style": true
      }
    ]
  ]
}

webpack antd 按需加载

原文:https://www.cnblogs.com/crazycode2/p/12117015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!