- Sass and Compass Designer's Cookbook
- Bass Jobsen
- 342字
- 2021-07-16 10:56:42
Using Sass on the command line
You can run Sass on the command line to compile your Sass files directly into the CSS code.
Getting ready
In the Installing Sass for command line usage recipe of this chapter, you have already read how to install Sass. Linux users have to open a terminal, while Mac users have to run the Terminal.app
, and Window users have to use the cmd
command for command-line usage.
How to do it...
Use the following steps to find out how to compile your Sass code in the command line:
- Create a Sass template called
first.scss
that contains the following SCSS code:$color: orange; p { color: $color; }
- Then, run the following command in your console:
sass first.scss
- You will find that the preceding command outputs the CSS code as it is shown here:
p { color: orange; }
How it works...
Firstly, notice that the example code in this recipe uses the newer SCSS syntax for Sass. In the Writing Sass or SCSS recipe of this chapter, you can read why this book uses the SCSS syntax in favor of the original indented Sass syntax.
The sass
command directly outputs the compiled CSS code to your console. To save the output in a file, you will have to set a second output argument, as follows:
sass first.scss first.css
The preceding command creates a new first.css
CSS file that contains the compiled CSS code.
There's more...
When compiling your Sass templates into CSS files, Sass does not only create CSS files, but also a folder called .sass-cache
. By default, Sass caches compile templates and partials. In the Working with partials recipe of this chapter, you can read what partials are. Caching of the compiled templates and partials makes recompiling after your changes faster.
You can use the --no-cache
option to disable caching.
The --compass
option makes Compass imports available and loads the project's configuration. You can read more about this option in the Extending Sass with Compass helper functions and more recipe of Chapter 6, Using Compass.
- Python自動化運(yùn)維快速入門
- 從學(xué)徒到高手:汽車電路識圖、故障檢測與維修技能全圖解
- Getting Started with Python Data Analysis
- MongoDB權(quán)威指南(第3版)
- 微服務(wù)架構(gòu)深度解析:原理、實踐與進(jìn)階
- PHP 7從零基礎(chǔ)到項目實戰(zhàn)
- JavaScript動態(tài)網(wǎng)頁編程
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器
- Visual C++程序設(shè)計與項目實踐
- Deep Learning for Natural Language Processing
- Drupal Search Engine Optimization
- Web前端測試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實踐
- JavaScript Mobile Application Development
- R語言:邁向大數(shù)據(jù)之路
- Java EE 程序設(shè)計