How to convert directory SASS/SCSS to CSS via command line?

前端 未结 5 1694
清酒与你
清酒与你 2020-12-23 11:27

I tried:

sass-convert --from scss --to css --recursive app/assets/stylesheets temp

But this only converts css to SASS, and I want the othe

5条回答
  •  攒了一身酷
    2020-12-23 12:11

    Use the sass command followed by the input file name and path, a colon (:) and the desired output file name and path. If the output file does not already exist Sass will generate it. For example,

    sass sass/main.scss:css/main.css
    

    However, this is a one-off command that would require being run every time you want to generate a new CSS file. A simpler and handier method is to use Sass's built-in --watch flag. This watches for changes to your Sass file and automatically runs the compile command each time you save changes.

    sass --watch sass/main.scss:css/main.css
    

    If you have multiple Sass files within a directory you can watch for changes to any file within that directory:

    sass --watch sass:css
    

    Sass also has four CSS output styles available: nested, expanded, compact and compressed. These can be used thus:

    sass --watch sass:css --style compressed
    

    Refer to the Sass documentation for more.

提交回复
热议问题