码迷,mamicode.com
首页 > Web开发 > 详细

webpack配置antd的按需加载

时间:2018-07-26 13:15:01      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:node   tle   res   ant   bpa   str   -o   run   one   

安装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的按需加载

标签:node   tle   res   ant   bpa   str   -o   run   one   

原文地址:https://www.cnblogs.com/camille666/p/webpack_antd.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!