脚本宝典收集整理的这篇文章主要介绍了react eject里面集成antd(或antd-mobile),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本文适合阅读对象:
使用create-react-app生成项目,并且在运行npm run eject之后,还想集成antd(antd-mobile)
1.安装babel-plugin-import:
npm install babel-plugin-import --save-dev
2.修改config/webpack.config.dev.js
和config/webpack.config.prod.js
:
找到这2个文件,并且在这2个文件中,找到以下部分:
// Process JS with Babel.
{
test: /.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
// 加上下面的plugins
plugins: [
['import', { libraryName: 'antd-mobile', style: 'css' }]// antd或antd-mobile
],
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
},
},
以上是脚本宝典为你收集整理的react eject里面集成antd(或antd-mobile)全部内容,希望文章能够帮你解决react eject里面集成antd(或antd-mobile)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。