使用antd-mobile,報錯 injectBabelPlugin is not a function

在create-react-app中,使用antd-mobile,報錯 injectBabelPlugin is not a function
 
查閱資料發現react-scripts 升級到 2.1.2 之後破壞了 react-app-rewired,react-app-rewired的新版本刪除全部方法injectBabelPlugin,這些方法被移動到一個名爲'customize-cra'的新包中了
 
修改方法:
1.確保已經下載customize-cra,less-loader
2.修改config-overrides文件爲
 
const {
  override,
  fixBabelImports,
} = require("customize-cra");
module.exports = override(
  fixBabelImports("import", {
    libraryName: "antd", style: 'css' 
  }),
);

 

 
 
運行成功
相關文章
相關標籤/搜索