我在 react.js 中使用react-app-rewired
. 我已经用 config-override.js 文件覆盖了配置。我在这里给它:
module.exports = function override(config, env) {
return {
...config,
output: {
filename: "static/js/radio-widget.js",
chunkFilename: "static/js/radio-widget.[name].js",
pathinfo: false,
futureEmitAssets: false,
publicPath: "/",
jsonpFunction: "webpackJsonp.my-embeddable-widget",
globalObject: "this",
},
}
}
这是我的 package.json:
{
"name": "myradio",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-app-rewired": "^2.1.8"
}
}
当我运行命令npm run build
时,我收到此错误,并且在提供静态 js 之后,一些 CSS 样式根本不起作用。
这是我附加的错误的屏幕截图。错误画面