0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自動生成ファイルがSource Treeのファイル差分に出てきてしまう場合の対処法

Posted at

備忘録。

事象

SourceTreeでコミットしようと変更ソースを確認していたところ、自動生成ファイル(css)が差分に出てきた。
Sassで実装していて、CSSファイルは自動コンパイルで生成されるからプロジェクト内の管理対象にしたくない。

原因

拡張機能のLive Sass Compilerを有効にしていて、
CSSファイルの出力先をプロジェクト内に設定していたため。
リアルタイムで実装しながらブラウザで確認したかった。

現設定

settings.json
"liveSassCompile.settings.formats": [
    // Sassの出力方法の設定
    {
      "format": "expanded", // expanded / compressed 2つから選択可
      "extensionName": ".css", // .css拡張子で出力
      "savePath": "~/../css" // すべての.scssファイルからの相対的な出力先のフォルダを指定
    }
  ],

対策

Live Sass Compilerの設定は変えずに、
Git側でCSSファイルを管理対象から外す設定を行う。

  1. Railsプロジェクトの直下にある”.gitignore”ファイルを開く
  2. 以下のコードを追加
.gitignore
# Live Sass Compiler の出力ファイルを除外
app/assets/css/*.css

Source Treeを確認し、.cssファイルが非表示になっていることを確認。
終わり。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?