webpack+react安装antd依赖

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依赖)