SASS 或 LESS 包装 [英] SASS or LESS packaging

查看:30
本文介绍了SASS 或 LESS 包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从不同的目录导入我的 scss 或更少的文件(无论哪种语言都无关紧要).我的电脑上的目录是这样的:

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

我试图避免 .scss 或 .less 文件中的相对路径来导入它们.我试图找到一个程序或一种我猜测打包文件的方式,而不必在 scss 或更少文件的 @import 上使用相对路径引用.有类似的东西还是我需要考虑另一个文件结构?文件结构的重点在于每个应用程序或网站都有一个库的参考点,而不是保留每个应用程序中的所有文件.

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.

推荐答案

Compass for Sass 提供了将库捆绑到 extensions 以便于重用的能力.他们的网站上有一个关于如何构建扩展的教程:http://compass-style.org/help/tutorials/extensions/

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.

在项目的 config.rb 中添加对扩展的引用:

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

require 'myextension'

如果您遵循推荐的 Sass 文件命名约定,则可以将它们导入任何 Sass 文件,如下所示:

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:

这篇关于SASS 或 LESS 包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆