Import Common Modules By Default When Compiling Scss
Solution 1:
Yes, this is indeed possible and in fact there is already an existing mature solution.
It's called Compass.
There's a lot of ambiguity about what Compass is, here's my kinda non-canonical attempt to resolve it.
Compass is three different things under one name:
- A standard for creating reusable SASS modules, just like you want. Those modules are called "Compass extensions". Compass extensions are basically pieces of SASS code organized in a certain manner, distributed as Ruby gems. They can also contain Ruby code used to introduce custom SASS functions.
- A
compass
command-line tool used to compile SASS with support for those extensions. Note that it's just a wrapper for the original SASS compiler, not an independent compiler. Here are its major features:compass
allows importing extensions using only their names and omittng paths, e. g.@import singularity
.- Relies on the
config.rb
configuration file.config.rb
is a piece of Ruby code. The best thing about it is that you can declare custom SASS functions with the powerful Ruby! - It also imposes certain file/folder structure for your SASS projects, called "a Compass project". A very basic Compass project consists of a config file, a folder for SASS code and a folder for resulting CSS code. Some Compass extensions contain templates that allow you create new Compass projects with somewhat more advanced structure (i recommend the Toolkit extension).
- A Compass extension of the same name (i. e.
@import compass
in SASS) that contains a lot of invaluable SASS mixins and functions.
If you're going to create a Compass extension for your needs, you can use this as a starter kit (note that the word "template" in the name of the starter kit means a different thing than above).
PS You're using pyScss, it claims to have full support for Compass. Yet, i consider this to be a kinda poor practice. I would rather use native SASS and Compass software. With such Ruby tools as RVM, RubyGems and Bundler, it's very simple to do and to maintain, even when your project is not in Ruby. The complexity of your project increases, but it pays you off with the simplicity of using native tools rather than some dubious ports. Also see How to use Compass/Sass with Django.
Also have a look at Grunt and Yeoman, which are considered to be the most modern practices that improve your development workflow.
References
- Compass
- The format of Compass extensions' internals
- RubyGems, a package management system for software based on Ruby
- Toolkit, a Compass extension that contains numerous SASS goodies, including general-purpose templates of Compass projects
- Documentation for "Compass" Compass extension
- Compass-Extension-Template, a starter kit used to create new Compass extensions
- RVM, a tool to install the most recent versions of Ruby for Linux and Mac
- Bundler, a tool to manage gems per project (rather than per OS)
- How to use Compass/Sass with Django, a blog post by Eric Meyer encouraging to use native Compass command line tool rather than integrating SASS and Compass into your framework.
- Grunt, a tool to program and perform various development routines
- Yeoman, a collection of tools and best practices forming a modern development workflow; includes Grunt
Post a Comment for "Import Common Modules By Default When Compiling Scss"