1. 程式人生 > >使用antd-mobile,報錯 injectBabelPlugin is not a function

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

exp 報錯 運行 版本 方法 over cti -a const

在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", libraryDirectory: "es", style: ‘css‘ }), );

運行成功

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