美文网首页
webpack+react安装antd依赖

webpack+react安装antd依赖

作者: 墨墨_5e5f | 来源:发表于2018-04-21 17:52 被阅读0次

1.安装babel-plugin-import依赖以及antd

npm install antd babel-plugin-import --save-dev

2.修改webpack.config.js

query: {
                    presets: ['env', "react"],
                    plugins: [
                        [
                            "import",
                            {libraryName: "antd", style: 'css'}
                        ] //antd按需加载
                    ]
                }

3.新建.babelrc配置文件

{
    "presets":["env","react"],
    "plugins": [
        ["import", {
            "libraryName": "antd",
            "style": "css"
        }]
    ] //import js and css modularly
}

相关文章

网友评论

      本文标题:webpack+react安装antd依赖

      本文链接:https://www.haomeiwen.com/subject/vrfflftx.html