antd design 大小优化

antd design 直接引用的话体积较大,不压缩4M
可以通过 babel-plugin-import,实现按需加载,仅仅会加载用到的组件的js 和css

https://www.npmjs.com/package/babel-plugin-import

参考文档:https://ant.design/docs/react/introduce-cn

demo

{
                test: /\.jsx$/, loader: "babel",
                query: {
                    presets: ['es2015', 'react'],
                    "plugins": [["import", {
                        "libraryName": "antd",
                        "style": true
                    }
                    ]]
                }
            }

你可能感兴趣的:(antd design 大小优化)