sass --watch with automatic minify?

懵懂的女人 提交于 2020-11-25 04:41:06

问题


Is there a way to run:

sass --watch a.scss:a.css

but have a.css end up being minified?

How would I avoid having to run a separate minification step as I compile my stylesheet?


回答1:


sass --watch a.scss:a.css --style compressed

Consult the documentation for updates:

  • http://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass
  • http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style



回答2:


If you are using JetBrains editors like IntelliJ IDEA, PhpStorm, WebStorm etc. Use the following settings in Settings > File Watchers.

  1. Convert style.scss to style.css set the arguments

    --no-cache --update $FileName$:$FileNameWithoutExtension$.css
    

    and output paths to refresh

    $FileNameWithoutExtension$.css
    
  2. Convert style.scss to compressed style.min.css set the arguments

    --no-cache --update $FileName$:$FileNameWithoutExtension$.min.css --style compressed
    

    and output paths to refresh

    $FileNameWithoutExtension$.min.css
    



回答3:


If you're using compass:

compass watch --output-style compressed



回答4:


There are some different way to do that

sass --watch --style=compressed main.scss main.css

or

sass --watch a.scss:a.css --style compressed

or

By Using visual studio code extension live sass compiler

see more



来源:https://stackoverflow.com/questions/8980398/sass-watch-with-automatic-minify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!