由 TypeScript 制作的 .gitignore .js 文件

Hum*_*erd 6 git gitignore

我有以下文件:

  • ActiveTask.ts
  • 活动任务.js
  • 控制器.ts
  • 控制器.js
  • _config.js
  • 其他文件.js

我只想承诺:

  • ActiveTask.ts
  • 控制器.ts
  • _config.js
  • 其他文件.js

如何忽略与 .ts 文件同名的 .js 文件?

lus*_*tig 5

  1. 更改文件的outDir条目tsconfig.json。这通常被称为,build但您可以随意命名。
// tsconfig.json (mine is in the root directory of my project)
{
    "compilerOptions": {  
      ...
      "outDir": "myAwesomeSuperCoolBuildDirectoryThatIPromiseToChangeAndNotJustCopyBlindlyFromStackOverflowBecauseThatWouldBeBad",  
      "sourceMap": true,  
      ...
    }
}
Run Code Online (Sandbox Code Playgroud)
  1. 添加outDir后跟 aforward slash --> / 到您的.gitignore文件
// .gitignore (mine is in the root directory of my project)
myAwesomeSuperCoolBuildDirectoryThatIPromiseToChangeAndNotJustCopyBlindlyFromStackOverflowBecauseThatWouldBeBad/
Run Code Online (Sandbox Code Playgroud)
  1. 删除旧的js.mapjsTypeScript 生成的文件并重新构建它们。这一次,它们将被构建在指定的目录中,并且会被 git 忽略。


Jeo*_*eon 1

对于您的具体情况,我建议:

.gitignore

*.js
!_*.js
Run Code Online (Sandbox Code Playgroud)

这将忽略所有 js 文件,除了以下划线开头的文件。