首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yarn start不能与react-app-rewired一起工作

Yarn start不能与react-app-rewired一起工作
EN

Stack Overflow用户
提问于 2019-05-23 18:04:41
回答 1查看 2.9K关注 0票数 3

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

代码语言:javascript
复制
$ 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看起来像这样:

代码语言:javascript
复制
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;
};
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-23 18:10:14

不要使用injectBabelPlugin此插件已弃用

像这样使用enter link description here

代码语言:javascript
复制
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" }
  })
);
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56272828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档