我正在使用react-app-rewired用package.json中的以下内容构建我的react应用程序。
"scripts": {
"format": "prettier --write",
"start": "PORT=3001 react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
},
但是当它生成时,它为我提供了以下样式表,该样式表被插入到index.html中,以下可能是默认样式。
<link href="/static/css/main.dc83752a.css" rel="stylesheet">
我希望对此进行如下更改。
<link href="static/css/main.dc83752a.css" rel="stylesheet">
我也尝试在根文件夹中使用config-overrides.js。但这没有用。谁能帮我解决问题? 我的config-overrides.js如下。
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// later after upgrade create-react-app to support
// webpack4 it can be removed becuase it now supports
// async css styles through mini-css-extract-plugin
// that future version of create-react-app also supports
// https://github.com/facebook/create-react-app/blob/next/packages/react-scripts/config/webpack.config.prod.js#L423
module.exports = function override(config, env) {
config.plugins[4] = new ExtractTextPlugin({
filename: 'static/css/[name].[contenthash:8].css',
allChunks: true,
});
return config;
}
答案 0 :(得分:1)
您能否检查并更新json包“ homepage”:“。”或改为“ /”并重新生成。 不需要覆盖。