我有一個 React 應用程式 (CRA),它超過了 heroku 的最大 slug 大小軟限制 (300MB),所以我使用這個解決方案來減小 slug 大小:
heroku buildpacks:add https://github.com/opencounter/heroku-buildpack-post-build-clean.git.slug-post-clean在專案根目錄添加檔案:
src
public
node_modules
但是,與此同時,我正在使用serve為我的應用程式提供服務,package.json:
...
"dependencies": {
...
"serve": "^12.0.1",
...
},
...
"scripts" : {
"start": "serve -s build",
}
剔除node_modules干脆也將排除serve,使Heroku的無法滿足我的應用程式。
如何在將“服務”及其依賴項列入白名單時減少 heroku slug 大小?
現在,我不包括一些大的獨立包(例如 @mui,@testing-library,等等),但是這是一個有點哈克。
uj5u.com熱心網友回復:
排除 后node-modules/.cache,slug 大小減少了 90% (~400M)。所以解決方法很簡單:
在.slug-post-clean,添加:
node-modules/.cache
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/351680.html
