Node.js 反应应用程序生产生成静态文件夹路径更改
我在package.json中使用react应用程序rewired构建我的react应用程序Node.js 反应应用程序生产生成静态文件夹路径更改,node.js,reactjs,webpack,build,Node.js,Reactjs,Webpack,Build,我在package.json中使用react应用程序rewired构建我的react应用程序 "scripts": { "format": "prettier --write", "start": "PORT=3001 react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test" }, 但是,当它构建时,它会将以下样式表作为默认样式
"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">
您是否可以检查并更新json包“主页”:“.”或“/”并再次重建。
不需要覆盖。您是否可以检查并更新json“主页”包中的“.”或“/”并再次重建。
不需要覆盖。是,谢谢。成功了。我用过这个。“主页”:“是的,谢谢。成功了。我用过这个。“主页”:”
<link href="static/css/main.dc83752a.css" rel="stylesheet">
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;
}