gpt4 book ai didi

reactjs - Yarn start 不适用于react-app-rewired

转载 作者:行者123 更新时间:2023-12-03 14:06:21 25 4
gpt4 key购买 nike

当我运行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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com