多个目录中的指南针源
您是否在多个目录中成功编译了 SASS?您可以设置罗盘来递归地监视目录吗?
我已经阅读了有关 add_import_path 的文档,但我真的很感激一些示例代码,因为我(我相当确定)从未编写过一行 ruby 代码。
我问的原因是我有几个共享一些标准 scss 的项目。我希望对共享 scss 的更改能够级联到所有项目。
谢谢。
Have you had success compiling SASS in multiple directories? Can you set up compass to recursively watch a directory?
I have read the documentation on add_import_path, but I would really appreciate some sample code, as I have (I am fairly certain) never written a line of ruby code.
The reason I ask is that I have several projects that share some standard scss. I would like changes to the shared scss to cascade to all projects.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您有以下目录结构:
然后调整您的 config.rb:
并在 main.scss 中包含其他 scss 文件:
Let's say you have the following directroy structure:
Then adjust your
config.rb
:and in your main.scss include the other scss files:
这是我的解决方案,基于两个 Ruby 脚本,支持批处理罗盘编译/监视多个独立的 SASS 项目。
包含 Ruby 文件的文件夹结构:
运行
compile.rb
和watch.rb
,其中几个参数代表包含config.rb
的模块文件夹的路径> 文件。即:
rubycompile.rb Module1/Module2/Module3/
compile.rb
即: ruby watch.rb Module1/ Module2/ Module3/
watch.rb
请注意,我们需要为每个指南针手表创建一个单独的线程(因为它们是阻塞进程)。
sleep(1)
是必要的,因为Compass::Exec::SubCommandUI
实际上并不是线程安全的,并且可能在同一模块上运行多个监视,而不是每个监视一个。如果发生这种情况,请尝试增加sleep
值。在所有模块中创建类似的 config.rb 文件。您可能必须使用
compass init
来获取compass识别的第一个config.rb
。配置文件
Here is my solution that supports batch compass compile/watch of multiple independent SASS projects, based on two Ruby scripts.
Folder structure with the Ruby files:
Run
compile.rb
andwatch.rb
with several arguments representing the paths to your module folders containing theconfig.rb
files.I.e. :
ruby compile.rb Module1/ Module2/ Module3/
compile.rb
I.e. :
ruby watch.rb Module1/ Module2/ Module3/
watch.rb
Notice that we need to create a separate thread for each compass watch (since they are blocking processes).
sleep(1)
is necessary becauseCompass::Exec::SubCommandUI
is not actually thread-safe and might run several watches on the same module, instead of one on each. In case that happens, try increasing thesleep
value.Create a similar
config.rb
file in all modules. You might have to usecompass init
to get the a firstconfig.rb
that compass recognizes.config.rb