当前位置:首页 > Web开发 > 正文

{"libraryName": "antd"

2024-03-31 Web开发

安置babel-plugin-import插件。下面要领二选一,,都可以实现antd的按需加载。

一、配置webpack.config.js文件

{ test: /.jsx?$/, exclude: /(node_modules|bower_components)/, use: [{ loader: ‘babel-loader‘ }], options: { "plugins": [ [ "import", { "libraryName": "antd", "style": true } ] ] } }

二、配置babelrc文件

{ "presets": ["env", "react"], "plugins": [ "transform-runtime", "transform-object-rest-spread", [ "import", { "libraryName": "antd", "style": true } ] ] }

webpack antd 按需加载

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/32730.html