babel-plugin-import按需加载不生效

背景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" }]]
            }
        },{
        .......
        }]
    }

 

你可能感兴趣的:(前端,webpack)