我在构建最新版本的 React 时遇到问题。当我运行 npm run build 时,它会分块构建。
构建结果:
File sizes after gzip:
34.45 KB build/static/js/1.2dd891c4.chunk.js
763 B build/static/js/runtime~main.229c360f.js
711 B build/static/js/main.f219991b.chunk.js
509 B build/static/css/main.ef7da6c0.chunk.css
我没有使用 webpack,也没有修改任何东西。我使用 create-react-app 安装了它。这是我的 package.json:
{
"name": "react-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
如何强制 react build 以以下格式构建:
711 B build/static/js/main.f219991b.js
509 B build/static/css/main.ef7da6c0.css
链接到包含构建文件的存储库: https ://github.com/Tararan/joes-coffee-store