背景react--Version15.4
框架比较老,项目突然需要使用的antd组件,找到一个2.X版本的antd做兼容
问题 项目打包过大
You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.
解决问题
配置项目
module: {
loaders: [{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['transform-object-assign'],
plugins: [["import", { libraryName: "antd", style: "css" }]]
}
},{
.......
}]
}