Which files or folders should be in .gitignore in React project?

Why bother? Just point your browser to gitignore.io and select all the tools and technologies you are using. You will automatically have a generated .gitignore file.


If you use create react app, then a good .gitignore for react projects is included. You definitely want to keep node_modules in gitignore.


# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Distribution directories
dist/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

See How to configure .gitignore file for more detials.

Dependencies

/node_modules
/.pnp
.pnp.js
package-lock.json

Testing

/coverage

Production

/build

Misc

npm-debug.log*