- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行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;
};
最佳答案
不要使用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" }
})
);
关于reactjs - Yarn start 不适用于react-app-rewired,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56272828/
假设我有一个包含两个函数的模块,其中一个函数依赖于另一个函数: // example.js function A() { return "hello"; } function B() {
致力于将项目从 Mocha 过渡到 Jest,以利用运行测试的速度以及 Jest 框架本身并遇到问题。 Rewire在代码库中使用得相当广泛,我在运行 gulp-jest 任务时遇到问题,并且仅对于那
我使用带有react-rewired 包装器的rca。为了向 webpack 添加自定义配置,我创建了 config-overrides.js 文件,用于存储配置设置。我添加了一个 babel-plu
我有一个自定义模块 tokens.js,它具有通过 npm 请求模块 发出请求的功能。它看起来像这样: 'use strict'; let request = require('request');
我有反应项目。当我使用 craco build 时,出现以下错误: node_modules/@react-navigation/core/lib/module/getStateFromPat
当我运行yarn start时,我得到以下输出 $ yarn start yarn run v1.15.2 $ react-app-rewired start The "injectBabelPlug
我有一个高阶组件: import React from 'react'; function withMUI(ComposedComponent) { return class withMUI {
我正在尝试使用 nyc 获取覆盖率报告,如果我不使用 cross-env 插件,它会很好地工作。 cross-env NODE_ENV=test nyc mocha --ui bdd --report
我正在尝试将 rewire 与我的 Karma(Webpack + Typescript)单元测试一起使用。我的单元测试是用 Typescript 编写的,与 Webpack 捆绑在一起,然后与 Ka
我正在尝试使用 babel-plugin-rewire 模拟另一个文件中的函数。此函数未导出,但由该文件的默认导出调用。 meteor 1.6.1 "babel-plugin-rewire": "^1
我有一个用 create-react-app 做的项目它一直运行良好,合并了一个模板,一切都很好,直到我想开始使用 TypeScript , 我遵循了 documentation 的建议, 我配置了
注意:我的目标是为项目带来 Rewire 的功能。无论是使用 Rewire 包、babel-plugin-rewire 还是任何其他满足我目标的库。考虑到这一点,这里是细节: 我正在尝试使用 Moch
我正在使用 TypeScript 开发一个 React-Native 项目。要编写我的单元测试,我想使用 babel-plugin-rewire模拟我的模块导入。但是,TypeScript 在从 ES
我在 React/Flux 应用程序中的 require 方法之前使用 rewire 来加载组件。但安装后我收到此错误: ERROR in ./~/rewire/lib/rewire.js Modul
我正在尝试 stub 一个module.exports函数。但我有一些麻烦。我会给你一个情况的sudo代码。 MyController.js const sendOTPOnPhone = rewire
在测试具有定时间隔的设置时,我遇到了这个问题。 首先,我使用的是sinon's fakeTimers创造合适的时机环境。 rewire用作依赖注入(inject)库。 问题是,当涉及到重新布线时,有时
我正在使用 create-react-app + typescript ,我想添加绝对路径。 我正在努力达到可以使用绝对路径的程度,如下所示: 而不是 import x from '../../../
我正在尝试在 reactjs 项目中使用 mobx。我已经使用 yarn add 命令安装了这些包: yarn add mobx mobx-react react-app-rewired react-
我正在使用 react-app-rewired 因为我在我的项目中使用了网络 worker 。因此,当我尝试构建时一切顺利,但在构建文件夹中没有 index.html 或任何 js 文件。我做错了什么
编辑:有人指出 rewire 文档中明显的内容,很快就回答了这个问题。 请注意,我将我的模块包装在 IIFE 中,因为我试图获取 Node 停止提示严格模式之外的 block 范围声明。不使用 IIF
我是一名优秀的程序员,十分优秀!