【问题标题】:Yarn start doesn't work with react-app-rewired纱线开始不适用于 react-app-rewired
【发布时间】:2019-10-09 21:17:11
【问题描述】:

当我运行 yarn start 时,我得到以下输出

$ yarn start
yarn run v1.15.2
$ react-app-rewired start
The "injectBabelPlugin" helper has been deprecated as of v2.0. You can use customize-cra plugins in replacement - https://github.com/arackaf/customize-cra#available-plugins
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我尝试阅读文档:https://github.com/arackaf/customize-cra#available-plugins,但由于我是 React 和 npm 的新手,所以对我来说没有多大意义,我不知道用哪个插件替换已弃用的帮助程序

我的config-overrides.js 看起来像:

const { injectBabelPlugin } = require('react-app-rewired');
const rewireLess = require('react-app-rewire-less');

module.exports = function override(config, env) {
   config = injectBabelPlugin(['import', { libraryName: 'antd', style: true }], config);  // change importing css to less
   config = rewireLess.withLoaderOptions({
       modifyVars: {
           "@primary-color": "#1DA57A"
       },
   })(config, env);
    return config;
};

【问题讨论】:

    标签: reactjs npm yarnpkg antd


    【解决方案1】:

    不要使用 injectBabelPlugin 这个 Pugin 已被弃用

    像这样使用enter link description here

    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" }
      })
    );
    

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 2020-10-16
      • 2022-01-21
      • 2022-07-22
      • 2020-05-11
      • 1970-01-01
      • 2021-01-05
      • 1970-01-01
      • 2019-01-21
      相关资源
      最近更新 更多