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
|
8 | This plugin requires Grunt `~0.4.0`
|
9 |
|
10 | If 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
|
13 | npm install grunt-contrib-sass --save-dev
|
14 | ```
|
15 |
|
16 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
|
17 |
|
18 | ```js
|
19 | grunt.loadNpmTasks('grunt-contrib-sass');
|
20 | ```
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | ## Sass task
|
26 | _Run this task with the `grunt sass` command._
|
27 |
|
28 | This 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
|
32 | Type: `Boolean`
|
33 |
|
34 | Show a full traceback on error.
|
35 |
|
36 | #### unixNewlines
|
37 | Type: `Boolean`
|
38 |
|
39 | Force Unix newlines in written files.
|
40 |
|
41 | #### check
|
42 | Type: `Boolean`
|
43 |
|
44 | Just check syntax, don't evaluate.
|
45 |
|
46 | #### style
|
47 | Type: `String`
|
48 |
|
49 | Output style. Can be `nested` (default), `compact`, `compressed`, or `expanded`.
|
50 |
|
51 | #### precision
|
52 | Type: `Number`
|
53 |
|
54 | How many digits of precision to use when outputting decimal numbers. Defaults to 3.
|
55 |
|
56 | #### quiet
|
57 | Type: `Boolean`
|
58 |
|
59 | Silence warnings and status messages during compilation.
|
60 |
|
61 | #### compass
|
62 | Type: `Boolean`
|
63 |
|
64 | Make Compass imports available and load project configuration.
|
65 |
|
66 | #### debugInfo
|
67 | Type: `Boolean`
|
68 |
|
69 | Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.
|
70 |
|
71 | #### lineNumbers
|
72 | Type: `Boolean`
|
73 |
|
74 | Emit comments in the generated CSS indicating the corresponding source line.
|
75 |
|
76 | #### loadPath
|
77 | Type: `String|Array`
|
78 |
|
79 | Add a (or multiple) Sass import path.
|
80 |
|
81 | #### require
|
82 | Type: `String|Array`
|
83 |
|
84 | Require a (or multiple) Ruby library before running Sass.
|
85 |
|
86 | #### cacheLocation
|
87 | Type: `String`
|
88 |
|
89 | The path to put cached Sass files. Defaults to `.sass-cache`.
|
90 |
|
91 | #### noCache
|
92 | Type: `Boolean`
|
93 |
|
94 | Don't cache to sassc files.
|
95 |
|
96 | #### bundleExec
|
97 | Type: `Boolean`
|
98 |
|
99 | Run `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
|
106 | grunt.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 |
|
130 | grunt.loadNpmTasks('grunt-contrib-sass');
|
131 |
|
132 | grunt.registerTask('default', ['jshint', 'sass']);
|
133 | ```
|
134 |
|
135 | #### Compile
|
136 |
|
137 | ```javascript
|
138 | grunt.initConfig({
|
139 | sass: {
|
140 | dist: {
|
141 | files: {
|
142 | 'main.css': 'main.scss'
|
143 | }
|
144 | }
|
145 | }
|
146 | });
|
147 | ```
|
148 |
|
149 | #### Concat and compile
|
150 |
|
151 | If 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
|
154 | grunt.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 |
|
170 | You can specify multiple `destination: source` items in `files`.
|
171 |
|
172 | ```javascript
|
173 | grunt.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 |
|
200 | Task submitted by [Sindre Sorhus](http://github.com/sindresorhus)
|
201 |
|
202 | *This file was generated on Tue Mar 26 2013 16:59:50.*
|