コンパイル とは

コンパイル とは?

今まで「コンパイル」って聞かれたら、「機械語に訳す」っていう認識だった。
でも、sass から cssコンパイルするって聞いて、悩んだ。
調べると、「とあるプログラミング言語で書かれた記述を別の言語に変換すること」らしい。
つまり、sass で書いたものを、css 形式に変換することだと。

今回のsass から css のような同じレベル間のコンパイルは、
「トランスパイラ」や「クロスコンパイラー」と呼ぶそう。

でも、この(sass をcssコンパイルする)必要性ってあるのかな?

以下の sass の公式ドキュメントの文章によると、ざっくり要約すると、sass は css をアップデートしたもの。
そして、導入するなら「sass コマンドを使って、cssコンパイルしてね!」って記載がある。
そして、sass は「プリプロセッサ(preprocessor)」というもので、これは、
とあるプログラムが処理される前に、処理されるプログラムのこと。
こういったプログラミング言語(例、C言語)は、コンパイルが必要っていう理解になりました。

# Preprocessing

CSS on its own can be fun, but stylesheets are getting larger, more complex, and harder to maintain. This is where a preprocessor can help. Sass has features that don't exist in CSS yet like nesting, mixins, inheritance, and other nifty goodies that help you write robust, maintainable CSS.


Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your website.


The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the sass command. You'll need to tell Sass which file to build from, and where to output CSS to. For example, running sass input.scss output.css from your terminal would take a single Sass file, input.scss, and compile that file to output.css.

参考サイト