antd-mobile 无法加载react-app-rewired

const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {

config = injectBabelPlugin(['import', { libraryName: 'antd-mobile', style: 'css' }], config);
return config;

};
我按照官网的步骤来的,但是控制台报错
yarn run v1.7.0
$ react-app-rewired start
injectBabelPlugin is not a function
errorinfo Visit Command failed with exit code 1.
https://yarnpkg.com/en/docs/c... for documentation about this command.

Process finished with exit code 1

阅读 2.6k
1 个回答

已经解决,解决方案
make sure u installed 'customize-cra' and react-app-rewired@2.x
make sure u installed 'less' and 'less-loader'
and then here is the config-overrides.js
const {
override,
fixBabelImports,
addLessLoader,
} = require("customize-cra");

module.exports = override(
fixBabelImports("import", {

libraryName: "antd", libraryDirectory: "es", style: true // change importing css to less

}),
addLessLoader({

javascriptEnabled: true,
modifyVars: { "@primary-color": "#1DA57A" }

})
);

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题