我如何创建 SASS 混合并在每个项目中使用 [英] How can i create SASS mixins and use in every project

查看:51
本文介绍了我如何创建 SASS 混合并在每个项目中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过简单地使用@import "mixinfile" 来创建一个包含不同 mixin 的 scss 文件,我想在任何项目中使用它,而不是在每个项目中复制该文件.类似于在 Windows 中向路径添加文件夹.我该怎么做?

I want to create a scss file with different mixins that I want to use in any project by simply using @import "mixinfile" and not to copy that file in every project. Similar to adding a folder to path in windows. How can I do that?

推荐答案

Compass 是 Sass 框架,它不仅提供了大量有用的函数和 mixin,而且允许您轻松创建自己的扩展.如果您将扩展程序捆绑为 gem(我个人建议这样做),您将不必记住将它放在文件系统上的位置.

Compass is Sass framework that not only provides a great deal of useful functions and mixins, but it allows you to easily create your own extensions. If you bundle your extension as a gem (which I personally recommend doing), you won't have to remember where you put it on the filesystem.

http://compass-style.org/help/tutorials/extensions/

当一个扩展作为 Ruby gem 安装时(这很容易做到,即使你对 Ruby 一无所知),你需要做的就是在你的 config.rb 文件中添加这样一行:

When an extension is installed as a Ruby gem (which is easy to do, even if you don't know a thing about Ruby), all you need to do is add a line like this to your config.rb file:

require "extension-name"

它将使您的扩展程序中的所有样式表都可以访问,就像您在项目目录中拥有它们的副本一样:

And it will make all of your stylesheets from within your extension accessible just like you had a copy of them in your project directory:

@import "extension-name/widgets";

Compass 的作者在这里有一个关于如何编写自己的扩展的截屏视频(不包括从扩展中创建一个 gem):

The author of Compass has a screencast of how to write your own extension here (doesn't cover creating a gem out of the extension):

http://chriseppstein.github.com/blog/2010/08/01/building-a-personal-framework/

这篇关于我如何创建 SASS 混合并在每个项目中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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