UNPKG

5.11 kBMarkdownView Raw
1# grunt-contrib-sass [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-sass.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-sass)
2
3> Compile Sass to CSS
4
5
6
7## Getting Started
8This plugin requires Grunt `~0.4.0`
9
10If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
11
12```shell
13npm install grunt-contrib-sass --save-dev
14```
15
16Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
17
18```js
19grunt.loadNpmTasks('grunt-contrib-sass');
20```
21
22
23
24
25## Sass task
26_Run this task with the `grunt sass` command._
27
28This task requires you to have [Ruby](http://www.ruby-lang.org/en/downloads/) and [Sass](http://sass-lang.com/download.html). 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 install sass` to install Sass.
29### Options
30
31#### trace
32Type: `Boolean`
33
34Show a full traceback on error.
35
36#### unixNewlines
37Type: `Boolean`
38
39Force Unix newlines in written files.
40
41#### check
42Type: `Boolean`
43
44Just check syntax, don't evaluate.
45
46#### style
47Type: `String`
48
49Output style. Can be `nested` (default), `compact`, `compressed`, or `expanded`.
50
51#### precision
52Type: `Number`
53
54How many digits of precision to use when outputting decimal numbers. Defaults to 3.
55
56#### quiet
57Type: `Boolean`
58
59Silence warnings and status messages during compilation.
60
61#### compass
62Type: `Boolean`
63
64Make Compass imports available and load project configuration.
65
66#### debugInfo
67Type: `Boolean`
68
69Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.
70
71#### lineNumbers
72Type: `Boolean`
73
74Emit comments in the generated CSS indicating the corresponding source line.
75
76#### loadPath
77Type: `String|Array`
78
79Add a (or multiple) Sass import path.
80
81#### require
82Type: `String|Array`
83
84Require a (or multiple) Ruby library before running Sass.
85
86#### cacheLocation
87Type: `String`
88
89The path to put cached Sass files. Defaults to `.sass-cache`.
90
91#### noCache
92Type: `Boolean`
93
94Don't cache to sassc files.
95
96#### bundleExec
97Type: `Boolean`
98
99Run `sass` with [bundle exec](http://gembundler.com/man/bundle-exec.1.html): `bundle exec sass`.
100
101### Examples
102
103#### Example config
104
105```javascript
106grunt.initConfig({
107 sass: { // Task
108 dist: { // Target
109 files: { // Dictionary of files
110 'main.css': 'main.scss', // 'destination': 'source'
111 'widgets.css': 'widgets.scss'
112 }
113 },
114 dev: { // Another target
115 options: { // Target options
116 style: 'expanded'
117 },
118 files: {
119 'main.css': 'main.scss',
120 'widgets.css': [
121 'button.scss',
122 'tab.scss',
123 'debug.scss' // Maybe you need one extra file in dev
124 ]
125 }
126 }
127 }
128});
129
130grunt.loadNpmTasks('grunt-contrib-sass');
131
132grunt.registerTask('default', ['jshint', 'sass']);
133```
134
135#### Compile
136
137```javascript
138grunt.initConfig({
139 sass: {
140 dist: {
141 files: {
142 'main.css': 'main.scss'
143 }
144 }
145 }
146});
147```
148
149#### Concat and compile
150
151If you specify an array of `src` paths they will be concatenated. However, in most cases you would want to just `@import` them into `main.scss`.
152
153```javascript
154grunt.initConfig({
155 sass: {
156 dist: {
157 files: {
158 'main.css': [
159 'reset.scss',
160 'main.scss'
161 ]
162 }
163 }
164 }
165});
166```
167
168#### Compile multiple files
169
170You can specify multiple `destination: source` items in `files`.
171
172```javascript
173grunt.initConfig({
174 sass: {
175 dist: {
176 files: {
177 'main.css': 'main.scss',
178 'widgets.css': 'widgets.scss'
179 }
180 }
181 }
182});
183```
184
185
186## Release History
187
188 * 2013-03-26   v0.3.0   Add support for `bundle exec`. Make sure `.css` files are compiled with SCSS.
189 * 2013-02-15   v0.2.2   First official release for Grunt 0.4.0.
190 * 2013-01-25   v0.2.2rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
191 * 2013-01-09   v0.2.2rc5   Updating to work with grunt v0.4.0rc5. Switching to this.files api. Add separator option.
192 * 2012-11-05   v0.2.0   Grunt 0.4 compatibility. Improve error message when Sass binary couldn't be found
193 * 2012-10-12   v0.1.3   Rename grunt-contrib-lib dep to grunt-lib-contrib.
194 * 2012-10-08   v0.1.2   Fix regression for darwin.
195 * 2012-10-05   v0.1.1   Windows support.
196 * 2012-09-24   v0.1.0   Initial release.
197
198---
199
200Task submitted by [Sindre Sorhus](http://github.com/sindresorhus)
201
202*This file was generated on Tue Mar 26 2013 16:59:50.*