Compile Compass to CSS
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-contrib-compass --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-contrib-compass');
Run this task with the grunt compass
command.
This task requires you to have Ruby and Compass. If you're on OS X or Linux you probably already have Ruby installed, try ruby -v
in your terminal. When you've confirmed you have Ruby installed, run gem update --system && gem install compass
to install Compass.
Compass operates on a folder level, because of this you don't specify any src/dest, but instead define the sassDir
and cssDir
options.
This plugin is only compatible with Grunt >= 0.4.x
.
Compass doesn't expose all of its options through the CLI, which this task makes use of. If you need an option not mentioned below you can either specify a path to a config.rb file in the config
option or embed it directly into the raw
option. Options defined in your Gruntfile will override those specified in your config.rb or raw
property. config
and raw
are mutually exclusive.
Specify the location of the Compass configuration file explicitly. Defaults to the same path as your Gruntfile.
String form of the Compass configuration file.
The the path Compass will run from. Defaults to the same path as your Gruntfile.
Tell compass what kind of application it is integrating with. Can be stand_alone
(default) or rails
.
The source directory where you keep your Sass stylesheets.
The target directory where you keep your CSS stylesheets.
Lets you specify which files you want to compile. Useful if you don't want to compile the whole folder. Globbing supported. Ignores filenames starting with underscore. Files must be in the directory you specified in sassDir
.
The directory where you keep your images.
The directory where you keep your JavaScript files.
The directory where you keep your fonts.
Use sensible defaults for your current environment. Can be: development
(default) or production
CSS output mode. Can be: nested
, expanded
, compact
, compressed
.
Make Compass asset helpers generate relative urls to assets.
Disable line comments.
Require the given Ruby library before running commands. This is used to access Compass plugins without having a project configuration file.
Load the framework or extensions found in the specified directory.
Load all the frameworks or extensions found in the specified directory.
Makes files under the specified folder findable by Sass's @import directive.
Causes the line number and file where a selector is defined to be emitted into the compiled CSS in a format that can be understood by the browser. Automatically disabled when using outputStyle: 'compressed'
.
Quiet mode.
Show a full stacktrace on error.
Allows Compass to overwrite existing files.
Dry Run. Tells you what it plans to do.
Turn off colorized output.
Run compass compile
with bundle exec: bundle exec compass compile
.
grunt.initConfig({
compass: { // Task
dist: { // Target
options: { // Target options
sassDir: 'sass',
cssDir: 'css',
environment: 'production'
}
},
dev: { // Another target
options: {
sassDir: 'sass',
cssDir: 'css'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('default', ['jshint', 'compass']);
grunt.initConfig({
compass: {
dist: {
options: {
config: 'config/config.rb'
}
}
}
});
grunt.initConfig({
compass: {
dist: {
options: {
config: 'config/config.rb', // css_dir = 'dev/css'
cssDir: 'dist/css'
}
}
}
});
grunt.initConfig({
compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css',
raw: 'preferred_syntax = :sass\n' // Use `raw` since it's not directly available
}
}
}
});
- 2013-02-27 v0.1.3 Fixes bundleExec.
- 2013-02-17 v0.1.2 Ensure Gruntfile.js is included on npm.
- 2013-02-15 v0.1.1 First official release for Grunt 0.4.0.
- 2013-02-05 v0.1.1rc8 Added new options: basePath specify, debugInfo.
- 2013-01-25 v0.1.1rc7 Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
- 2013-01-10 v0.1.1rc5 Updating to work with grunt v0.4.0rc5.
- 2012-10-22 v0.1.0 Initial release
Task submitted by Sindre Sorhus
This file was generated on Wed Feb 27 2013 23:08:31.