哪些文件或文件夹应该在 React 项目中的 .gitignore 中?

SAI*_*NIK 21 git gitignore reactjs

我正在制作一个反应项目并在笔记本电脑和 Windows 10 桌面上使用 Linux mint。我想知道,我应该将哪些文件或文件夹保留在 .gitignore 中,这样我就不必在切换计算机时清理缓存和安装 npm。

Pra*_*ant 34

何苦?只需将您的浏览器指向gitignore.io并选择您正在使用的所有工具和技术。您将自动生成一个.gitignore文件。

  • gitignore.io 生成的 React 默认的 `.gitignore` 非常基本,不会涵盖所有内容 - 它甚至不包含 `build` 文件夹。Facebook 的“.gitignore”应该涵盖所有内容 - https://github.com/facebook/react/blob/main/.gitignore (13认同)
  • @ChrisHalcrow 这是 React 的 gitignore,它不应该 100% 被认为是使用 React 库创建的项目的充分示例 (2认同)

Ham*_*oja 12

# 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
Run Code Online (Sandbox Code Playgroud)


Chr*_*sli 7

如果您使用 create React app,那么会包含一个适用于 React 项目的良好 .gitignore。你肯定想将 node_modules 保留在 gitignore 中。