• Stars
    star
    625
  • Rank 71,862 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Compile Compass to CSS.

grunt-contrib-compass v1.1.1 Build Status: Linux Build Status: Windows

Compile Sass to CSS using Compass

Getting Started

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');

Compass task

Run this task with the grunt compass command.

Compass is an open-source authoring framework for the Sass css preprocessor. It helps you build stylesheets faster with a huge library of Sass mixins and functions, advanced tools for spriting, and workflow improvements including file based Sass configuration and a simple pattern for building and using Compass extensions.

This task requires you to have Ruby, Sass, and Compass >=1.0.1 installed. If you're on OS X or Linux you probably already have Ruby installed; test with ruby -v in your terminal. When you've confirmed you have Ruby installed, run gem update --system && gem install compass to install Compass and Sass.

Compass operates on a folder level. Because of this you don't specify any src/dest, but instead define the sassDir and cssDir options.

Options

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.

sourcemap

Type: Boolean
Default: false

Generate Source Maps.

config

Type: String
Default: same path as your Gruntfile

Specify the location of the Compass configuration file explicitly.

raw

Type: String

String form of the Compass configuration file.

basePath

Type: String

The path Compass will run from. Defaults to the same path as your Gruntfile.

banner

Type: String

Prepend the specified string to the output file. Useful for licensing information. Note: This only works in combination with the specify option and can conflict with sourcemap generation.

app

Type: String
Default: stand_alone

Tell compass what kind of application it is integrating with. Can be stand_alone or rails.

sassDir

Type: String

The source directory where you keep your Sass stylesheets.

cssDir

Type: String

The target directory where you keep your CSS stylesheets.

specify

Type: String|Array

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. Paths are relative to the Gruntfile.

imagesDir

Type: String

The directory where you keep your images.

javascriptsDir

Type: String

The directory where you keep your JavaScript files.

fontsDir

Type: String

The directory where you keep your fonts.

environment

Type: String
Default: development

Use sensible defaults for your current environment. Can be: development or production

outputStyle

Type: String

CSS output mode. Can be: nested, expanded, compact, compressed.

relativeAssets

Type: Boolean

Make Compass asset helpers generate relative urls to assets.

noLineComments

Type: Boolean

Disable line comments.

httpPath

Type: String
Default: /

The path to the project when running within the web server.

cssPath

Type: String

The directory where the css stylesheets are kept. It is relative to the projectPath. Defaults to "stylesheets".

httpStylesheetsPath

Type: String
Default: httpPath + '/' + cssDir

The full http path to stylesheets on the web server.

sassPath

Type: String
Default: sass

The directory where the sass stylesheets are kept. It is relative to the projectPath.

imagesPath

Type: String
Default: images

The directory where the images are kept. It is relative to the projectPath.

httpImagesPath

Type: String
Default: httpPath + '/' + imagesDir

The full http path to images on the web server.

generatedImagesDir

Type: String
Default: value of imagesDir

The directory where generated images are kept. It is relative to the projectPath.

generatedImagesPath

Type: String
Default: value of projectPath/generatedImagesDir

The full path to where generated images are kept.

httpGeneratedImagesPath

Type: String
Default: httpPath + '/' + generatedImagesDir

The full http path to generated images on the web server.

spriteLoadPath

Type: String|Array
Default: value of imagesPath

Add additional locations to look for sprites. The imagesPath is always the last entry in this list.

javascriptsPath

Type: String
Default: projectPath/javascriptsDir

The full path to where javascripts are kept.

httpJavascriptsPath

Type: String
Default: httpPath + '/' + javascriptsDir

The full http path to javascripts on the web server.

fontsPath

Type: String
Default: projectPath/fontsDir

The full path to where font files are kept.

httpFontsPath

Type: String

The full http path to font files on the web server.

httpFontsDir

Type: String

The relative http path to font files on the web server.

extensionsPath

Type: String
Default: project_root/extensions

The full http path to the ad-hoc extensions folder on the web server. This is used to access compass plugins that have been installed directly to the project (e.g. through Bower) instead of globally as gems. Only Compass >=0.12.2

extensionsDir

Type: String

The relative http path to the ad-hoc extensions folder on the web server. Only Compass >=0.12.2

assetCacheBuster

Type: Boolean
Default: true

If set to false, this disables the default asset cache buster.

cacheDir

Type: String
Default: .sass-cache

The relative path to the folder where the sass cache files are generated.

require

Type: String|Array

Require the given Ruby library before running commands. This is used to access Compass plugins without having a project configuration file.

load

Type: String|Array

Load the framework or extensions found in the specified directory.

loadAll

Type: String|Array

Load all the frameworks or extensions found in the specified directory.

importPath

Type: String|Array

Makes files under the specified folder findable by Sass's @import directive.

debugInfo

Type: Boolean

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

Type: Boolean

Quiet mode.

trace

Type: Boolean

Show a full stacktrace on error.

force

Type: Boolean

Allows Compass to overwrite existing files.

boring

Type: Boolean

Turn off colorized output.

bundleExec

Type: Boolean

Run compass compile with bundle exec: bundle exec compass compile.

clean

Type: Boolean

Remove generated files and the sass cache. Runs compass clean instead of compass compile.

watch

Type: Boolean

Runs compass watch instead of compass compile. This will use Compass' native watch command to listen for changes to Sass files and recompile your CSS on changes. While much faster than running compass compile each time you want to compile your Sass, Compass becomes a blocking task. This means that if you would like to use it in conjunction with another blocking task, such as watch, you will need to use it in conjunction with a paralleling task such as grunt-concurrent.

Usage Examples

Example config

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']);

Example usage

Use external config file
grunt.initConfig({
  compass: {
    dist: {
      options: {
        config: 'config/config.rb'
      }
    }
  }
});
Override setting in external config file
grunt.initConfig({
  compass: {
    dist: {
      options: {
        config: 'config/config.rb',  // css_dir = 'dev/css'
        cssDir: 'dist/css'
      }
    }
  }
});
Use raw option
grunt.initConfig({
  compass: {
    dist: {
      options: {
        sassDir: 'sass',
        cssDir: 'css',
        raw: 'preferred_syntax = :sass\n' // Use `raw` since it's not directly available
      }
    }
  }
});

Release History

  • 2016-03-04   v1.1.1   Pass only compass package name, not full path.
  • 2016-02-15   v1.1.0   Use which to find compass binary cross platform. Update async and tmp dependencies.
  • 2015-09-29   v1.0.4   Use the compass flag for the httpPath option. Use single-quotes in the config.rb generated file.
  • 2015-04-02   v1.0.3   Add --config path before -- option/argument separator.
  • 2015-03-31   v1.0.2   Improve POSIX compliance.
  • 2014-09-08   v1.0.1   Use compass long flag for importPath.
  • 2014-09-05   v1.0.0   Fix bundleExec option on Windows.
  • 2014-07-31   v0.9.1   Fix npm peerDependency warnings.
  • 2014-06-24   v0.9.0   Add Compass version check to ensure only a supported version is used.
  • 2014-05-16   v0.8.0   Add spriteLoadPath option.
  • 2014-02-09   v0.7.2   Improve compatibility with Compass 0.13.
  • 2014-01-26   v0.7.1   Fix assetCacheBuster option.
  • 2013-12-07   v0.7.0   Add cacheDir option.
  • 2013-10-04   v0.6.0   Add watch option. Fix Compass errors not propagating.
  • 2013-08-8   v0.5.0   Add assetCacheBuster option.
  • 2013-07-28   v0.4.1   Fix banner option with .css.scss files.
  • 2013-07-19   v0.4.0   Add banner option. Show compilation time.
  • 2013-06-24   v0.3.0   Add extensionDir and extensionPath options. Requires Compass >=0.12.2.
  • 2013-04-11   v0.2.0   Add clean option. Expose raw options as Grunt options. Fix detection of Nothing to compile situation.
  • 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 Apr 06 2016 15:17:42.

More Repositories

1

grunt

Grunt: The JavaScript Task Runner
JavaScript
12,273
star
2

grunt-contrib-watch

Run tasks whenever watched files change.
JavaScript
1,982
star
3

grunt-contrib-uglify

Minify files with UglifyJS.
JavaScript
1,483
star
4

grunt-contrib-imagemin

Minify PNG, JPG, GIF and SVG images.
JavaScript
1,214
star
5

grunt-contrib-sass

Compile Sass to CSS.
JavaScript
848
star
6

grunt-contrib-concat

Concatenate files.
JavaScript
811
star
7

grunt-contrib-cssmin

Compress CSS files.
JavaScript
793
star
8

grunt-contrib-copy

Copy files and folders.
JavaScript
726
star
9

grunt-contrib-connect

Start a static web server.
JavaScript
714
star
10

grunt-contrib-jshint

Validate files with JSHint.
JavaScript
709
star
11

grunt-cli

Grunt's command line interface.
JavaScript
707
star
12

grunt-contrib-less

Compile LESS files to CSS.
JavaScript
667
star
13

grunt-contrib-clean

Clear files and folders.
JavaScript
512
star
14

grunt-contrib-requirejs

Optimize RequireJS projects using r.js.
JavaScript
504
star
15

grunt-contrib

[DEPRECATED] A collection of common grunt tasks.
JavaScript
475
star
16

grunt-contrib-htmlmin

Minify HTML.
JavaScript
425
star
17

grunt-contrib-jasmine

Run jasmine specs headlessly through Headless Chrome
JavaScript
354
star
18

grunt-contrib-compress

Compress files and folders.
JavaScript
345
star
19

grunt-contrib-coffee

Compile CoffeeScript files to JavaScript.
JavaScript
329
star
20

grunt-contrib-pug

Compile Pug templates.
JavaScript
328
star
21

grunt-contrib-handlebars

Precompile Handlebars templates to JST file.
JavaScript
282
star
22

grunt-contrib-csslint

Lint CSS files.
JavaScript
240
star
23

grunt-contrib-qunit

Run QUnit tests in Headless Chrome.
JavaScript
214
star
24

grunt-contrib-livereload

Reload assets live in the browser.
JavaScript
202
star
25

grunt-init

Generate project scaffolding from a template.
JavaScript
193
star
26

grunt-contrib-stylus

Compile Stylus files to CSS.
JavaScript
174
star
27

grunt-init-gruntfile

Create a basic Gruntfile with grunt-init.
JavaScript
156
star
28

gruntjs.com

Grunt website
Less
155
star
29

grunt-contrib-jst

Compile underscore templates to JST file.
JavaScript
113
star
30

grunt-lib-phantomjs

Grunt and PhantomJS, sitting in a tree.
JavaScript
93
star
31

grunt-next

Grunt v1.0 alpha
JavaScript
84
star
32

grunt-docs

Grunt documentation. https://github.com/gruntjs/gruntjs.com
79
star
33

grunt-init-gruntplugin

Create a gruntplugin module with grunt-init, including Nodeunit unit tests.
JavaScript
77
star
34

grunt-contrib-yuidoc

Compile YUIDoc Documentation.
JavaScript
75
star
35

grunt-contrib-nodeunit

Run Nodeunit unit tests.
JavaScript
70
star
36

grunt-init-jquery

Create a jQuery plugin with grunt-init, including QUnit unit tests.
JavaScript
58
star
37

grunt-contrib-symlink

Create symbolic links.
JavaScript
56
star
38

grunt-init-node

Create a Node.js module with grunt-init, including Nodeunit unit tests.
JavaScript
55
star
39

grunt-contrib-bump

A work-in-progress Grunt plugin for bumping a version number in JSON files.
JavaScript
52
star
40

grunt-init-commonjs

Create a commonjs module with grunt-init, including Nodeunit unit tests.
JavaScript
17
star
41

grunt-contrib-internal

Internal tasks for managing the grunt-contrib project.
JavaScript
16
star
42

grunt-init-gruntfile-sample

This is sample output generated by the grunt-init "gruntfile" template.
JavaScript
14
star
43

grunt-init-jquery-sample

This is sample output generated by the grunt-init "jquery" template.
JavaScript
12
star
44

grunt-lib-contrib

Common functionality shared across grunt-contrib tasks.
JavaScript
12
star
45

example-subgrunt

Run a Gruntfile in multiple subdirectories.
JavaScript
11
star
46

grunt-contrib-mincss

Renamed to grunt-contrib-cssmin.
9
star
47

grunt-init-gruntplugin-sample

This is sample output generated by the grunt-init "gruntplugin" template.
JavaScript
9
star
48

grunt-init-node-sample

This is sample output generated by the grunt-init "node" template.
JavaScript
8
star
49

grunt-known-options

The known options used in Grunt
JavaScript
7
star
50

grunt-init-commonjs-sample

This is sample output generated by the grunt-init "commonjs" template.
JavaScript
7
star
51

clone-repos

Quickly clone all gruntjs repos (for grunt development)
Ruby
6
star
52

grunt-lib-legacyhelpers

Some old grunt helpers provided for backwards compatability.
JavaScript
6
star
53

grunt-legacy-util

deprecated utility methods
JavaScript
5
star
54

grunt-legacy-log

The Grunt logger.
JavaScript
5
star
55

rfcs

RFCs for changes to Grunt
4
star
56

grunt-legacy-log-utils

Static methods for the Grunt 0.4.x logger.
JavaScript
4
star
57

grunt-plugin-list

[Deprecated] Generates a list of all grunt plugins as json
JavaScript
4
star
58

grunt-legacy-event-logger

Event logger for Grunt legacy libs.
JavaScript
3
star
59

grunt-legacy-config

Grunt's config methods, as a standalone library.
JavaScript
2
star
60

grunt-legacy-option

Grunt's option methods, as a standalone library.
JavaScript
1
star
61

grunt-legacy-cli

Grunt's CLI methods, as a standalone library.
JavaScript
1
star
62

grunt-legacy-task

Grunt's task methods, as a standalone library.
JavaScript
1
star