Reusing Dependencies Between Builds #17276
|
I've noticed that Create React App can spend a noticeable amount of time reinstalling or processing dependencies during repeated builds, especially in CI environments. Is there a recommended way to make dependency handling more efficient between builds without relying on a custom webpack configuration? For example, should we mainly rely on npm's cache, or is there something specific in react-scripts that can be configured to improve build performance? |
Replies: 1 comment
|
For CI, the main approach is to cache the package manager's cache and reuse the installed dependencies when possible. With npm, for example, GitHub Actions can cache the npm cache using - uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
If builds themselves are the bottleneck, caching dependencies will help with installation time, but it won't necessarily make the webpack compilation significantly faster. |
For CI, the main approach is to cache the package manager's cache and reuse the installed dependencies when possible.
With npm, for example, GitHub Actions can cache the npm cache using
actions/setup-node:react-scriptsitself doesn't provide a separate dependency-cache configuration. Dependency installation and caching are primarily handled by the package manager and CI environment.If builds themselves are the bottleneck, caching dependencies will help with installation time, but it won't necessarily make the webpack compilation significantly faster.