user7591226
user7591226

Reputation:

Can anyone tell me how to compile sass into css automatically?

I had to rewrite this every time I want to see a live preview.

sass stylesheet.scss stylesheet.css

Upvotes: 9

Views: 11117

Answers (5)

winhole14
winhole14

Reputation: 16

Sass can be compiled automatically using below command:

sass --watch SASS_SOURCE_PATH:CSS_BUILD_PATH --style=expanded --no-source-map

Where:

  • SASS_SOURCE_PATH: Path of sass file

  • CSS_BUILD_PATH: Path of build CSS file. Where do you want to save CSS file

  • --no-source-map: will not output a map file, which is not readable.

  • --style=expanded: will expand CSS to human readable.

Upvotes: -2

Seyed Kazem Mousavi
Seyed Kazem Mousavi

Reputation: 457

you can use this code

sass --watch file.sass:file.css

or

sass --watch foldersass:foldercss

Upvotes: 1

Ashley Johnson
Ashley Johnson

Reputation: 206

I use sass --watch stylesheet.scss:stylesheet.css. When saving your .scss file, it'll automatically update the .css file.

You might also consider sass --watch stylesheet.scss:stylesheet.css --style expanded --sourcemap=none to keep the .css file readable.

I'd recommend the Sass Workflow class on Udemy.

Upvotes: 19

Marko Bajlovic
Marko Bajlovic

Reputation: 323

Try out Grunt or Gulp with Sass: A great tutorial: https://www.taniarascia.com/getting-started-with-grunt-and-sass/

Upvotes: 3

gwally
gwally

Reputation: 3547

You need something to compile it automatically. As an example, there are solutions that use node.js to automatically compile for you on your computer. One tool is Foundation for Websites by Zurb.

You can install the application which will automatically compile sass for you.

For more information, check out: http://foundation.zurb.com/sites/download.html/

Upvotes: 1

Related Questions