libsass-python编译文件 [英] libsass-python compile a file
问题描述
我最近发现了一个很棒的Python库,可以非常快速地编译SASS! libsass-python 看起来非常好而且非常快
I recently find a fantastic python library compiling SASS really fast! libsass-python seems to be very good and really fast
如何使用它监视sass文件夹或文件中的任何更改并在CSS中进行编译?我不明白如何传递文件以及如何使用--watch选项
How I can use it to watch for any change in a sass folder or file and compile it in CSS ? I do not understand how to pass a file and how to use --watch option
谢谢!
推荐答案
根据帮助说明(http://hongminhee.org/libsass-python/sassc.html ),您只需使用:
According to the help instructions (http://hongminhee.org/libsass-python/sassc.html), you can watch for modifications in file simply with :
$ sassc --watch source.scss target.css
现在,我想让您查看文件夹中包含的所有文件,而且命令行实用程序似乎也没有提供该文件.
Now, I get you want to watch all the files contained in a folder, and it doesn't seem that the command-line utility provides that.
据我所知,我将看到两种可能的解决方法.
For what I can tell, I'd see two possible workarounds.
1:启动几个 sassc
实例,每个文件一个.它很脏,但是不需要任何努力,如果您没有太多文件,我想也可以.不要忘记终止所有过程(例如,使用 killall
).
1 : launching several sassc
instances, one for each of your files. It pretty dirty, but doesn't require any effort, and I guess it is okay if you don't have too many files. Don't forget to terminate all the process (with killall
for instance).
$ sassc --watch a.scss a.css & sassc --watch b.scss b.css # etc.
这确实不是处理问题的好方法,但是如果您急于忙,可以将其视为临时解决方案.
This is really not a great way to handle things, but it can be considered a temporary solution if you're in a hurry.
2:在python程序中使用libsass,当保存监视文件时,该程序会触发编译.为此,您可以使用另一个库,例如 watchdog 或
2 : use libsass inside a python program that would trigger compilation when a watched file is saved. To that end you can use another library like watchdog or pyinotify.
这似乎是处理问题的更好方法.
This seems to be a much better way to handle things.
希望这对您有所帮助,祝您好运!
Hope this was helpful, good luck !
这篇关于libsass-python编译文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!