SASS or LESS packaging

旧时模样 提交于 2019-12-17 21:16:04

问题


I want to be able to import my scss or less file (either language doesn't matter) from different directories. The directories are this on my computer:

apps/myapp/includes/css/

&

framework/2.3/lib/framework/2.3/css

I am trying to avoid relative paths in the .scss or the .less files to import them. I am trying to find a program or a way I guess package the files without having to use relative path references on the @import of the scss or less file. Is there something like that or do I need to think of another file structure? The whole point of the file structure is for each app or website that is made there is a reference point for the library instead of keeping all of the files within each app.


回答1:


Compass for Sass offers the ability to bundle libraries into extensions for easy reuse. They have a tutorial on their site on how to build the extensions: http://compass-style.org/help/tutorials/extensions/

Using the extension in a project is a lot simpler than creating one.

Add a reference to your extension in your project's config.rb:

require 'myextension'

If you follow the recommended naming conventions for your Sass files, you can import them in any Sass file like so:

@import 'myextension';
@import 'myextension/specific/file';

Some existing Compass extensions:

  • Sassy Buttons
  • Color Schemer
  • Modular Scale



回答2:


Codekit for Mac has a feature called Frameworks:

Keep just one copy of a file on your drive and easily use it across many projects without worrying about file paths. No more copying files into every new site.

However, if you are using Compass (even with Codekit, I believe), you should follow cimmanon's advice and use Compass extensions. This is the solution I would recommend.



来源:https://stackoverflow.com/questions/15949004/sass-or-less-packaging

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