You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+74-39Lines changed: 74 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ It allows you to natively compile .scss files to css at incredible speed and aut
30
30
31
31
Find it on npm: <https://www.npmjs.com/package/node-sass>
32
32
33
-
Follow @nodesass on twitter for release updates: https://twitter.com/nodesass
33
+
Follow @nodesass on twitter for release updates: <https://twitter.com/nodesass>
34
34
35
35
## Install
36
36
@@ -40,7 +40,7 @@ npm install node-sass
40
40
41
41
Some users have reported issues installing on Ubuntu due to `node` being registered to another package. [Follow the official NodeJS docs](https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager) to install NodeJS so that `#!/usr/bin/env node` correctly resolved.
42
42
43
-
Compiling on Windows machines requires the [node-gyp prerequisits](https://github.com/nodejs/node-gyp#on-windows).
43
+
Compiling on Windows machines requires the [node-gyp prerequisites](https://github.com/nodejs/node-gyp#on-windows).
44
44
45
45
**Having installation troubles? Check out our [Troubleshooting guide](/TROUBLESHOOTING.md).**
46
46
@@ -60,16 +60,21 @@ var result = sass.renderSync({
60
60
```
61
61
62
62
## Options
63
+
63
64
### file
64
-
Type: `String`
65
-
Default: `null`
65
+
66
+
* Type: `String`
67
+
* Default: `null`
68
+
66
69
**Special**: `file` or `data` must be specified
67
70
68
71
Path to a file for [LibSass] to render.
69
72
70
73
### data
71
-
Type: `String`
72
-
Default: `null`
74
+
75
+
* Type: `String`
76
+
* Default: `null`
77
+
73
78
**Special**: `file` or `data` must be specified
74
79
75
80
A string to pass to [LibSass] to render. It is recommended that you use `includePaths` in conjunction with this so that [LibSass] can find files when using the `@import` directive.
@@ -78,10 +83,11 @@ A string to pass to [LibSass] to render. It is recommended that you use `include
78
83
79
84
**This is an experimental LibSass feature. Use with caution.**
*`url (String)` - the path in import **as-is**, which [LibSass] encountered
86
92
*`prev (String)` - the previously resolved path
87
93
*`done (Function)` - a callback function to invoke on async completion, takes an object literal containing
@@ -115,13 +121,16 @@ Starting from v3.0.0:
115
121
`functions` is an `Object` that holds a collection of custom functions that may be invoked by the sass files being compiled. They may take zero or more input parameters and must return a value either synchronously (`return ...;`) or asynchronously (`done();`). Those parameters will be instances of one of the constructors contained in the `require('node-sass').types` hash. The return value must be of one of these types as well. See the list of available types below:
116
122
117
123
#### types.Number(value [, unit = ""])
124
+
118
125
*`getValue()`/ `setValue(value)` : gets / sets the numerical portion of the number
119
126
*`getUnit()` / `setUnit(unit)` : gets / sets the unit portion of the number
120
127
121
128
#### types.String(value)
129
+
122
130
*`getValue()` / `setValue(value)` : gets / sets the enclosed string
123
131
124
132
#### types.Color(r, g, b [, a = 1.0]) or types.Color(argb)
133
+
125
134
*`getR()` / `setR(value)` : red component (integer from `0` to `255`)
126
135
*`getG()` / `setG(value)` : green component (integer from `0` to `255`)
127
136
*`getB()` / `setB(value)` : blue component (integer from `0` to `255`)
@@ -136,21 +145,25 @@ var Color = require('node-sass').types.Color,
136
145
```
137
146
138
147
#### types.Boolean(value)
148
+
139
149
*`getValue()` : gets the enclosed boolean
140
150
*`types.Boolean.TRUE` : Singleton instance of `types.Boolean` that holds "true"
141
151
*`types.Boolean.FALSE` : Singleton instance of `types.Boolean` that holds "false"
142
152
143
153
#### types.List(length [, commaSeparator = true])
154
+
144
155
*`getValue(index)` / `setValue(index, value)` : `value` must itself be an instance of one of the constructors in `sass.types`.
145
156
*`getSeparator()` / `setSeparator(isComma)` : whether to use commas as a separator
146
157
*`getLength()`
147
158
148
159
#### types.Map(length)
160
+
149
161
*`getKey(index)` / `setKey(index, value)`
150
162
*`getValue(index)` / `setValue(index, value)`
151
163
*`getLength()`
152
164
153
165
#### types.Null()
166
+
154
167
*`types.Null.NULL` : Singleton instance of `types.Null`.
155
168
156
169
#### Example
@@ -174,55 +187,65 @@ sass.renderSync({
174
187
```
175
188
176
189
### includePaths
177
-
Type: `Array<String>`
178
-
Default: `[]`
190
+
191
+
* Type: `Array<String>`
192
+
* Default: `[]`
179
193
180
194
An array of paths that [LibSass] can look in to attempt to resolve your `@import` declarations. When using `data`, it is recommended that you use this.
181
195
182
196
### indentedSyntax
183
-
Type: `Boolean`
184
-
Default: `false`
197
+
198
+
* Type: `Boolean`
199
+
* Default: `false`
185
200
186
201
`true` values enable [Sass Indented Syntax](http://sass-lang.com/documentation/file.INDENTED_SYNTAX.html) for parsing the data string or file.
187
202
188
203
__Note:__ node-sass/libsass will compile a mixed library of scss and indented syntax (.sass) files with the Default setting (false) as long as .sass and .scss extensions are used in filenames.
189
204
190
205
### indentType (>= v3.0.0)
191
-
Type: `String`
192
-
Default: `space`
206
+
207
+
* Type: `String`
208
+
* Default: `space`
193
209
194
210
Used to determine whether to use space or tab character for indentation.
195
211
196
212
### indentWidth (>= v3.0.0)
197
-
Type: `Number`
198
-
Default: `2`
199
-
Maximum: `10`
213
+
214
+
* Type: `Number`
215
+
* Default: `2`
216
+
* Maximum: `10`
200
217
201
218
Used to determine the number of spaces or tabs to be used for indentation.
202
219
203
220
### linefeed (>= v3.0.0)
204
-
Type: `String`
205
-
Default: `lf`
221
+
222
+
* Type: `String`
223
+
* Default: `lf`
206
224
207
225
Used to determine whether to use `cr`, `crlf`, `lf` or `lfcr` sequence for line break.
208
226
209
227
### omitSourceMapUrl
210
-
Type: `Boolean`
211
-
Default: `false`
228
+
229
+
* Type: `Boolean`
230
+
* Default: `false`
231
+
212
232
**Special:** When using this, you should also specify `outFile` to avoid unexpected behavior.
213
233
214
234
`true` values disable the inclusion of source map information in the output file.
215
235
216
236
### outFile
217
-
Type: `String | null`
218
-
Default: `null`
237
+
238
+
* Type: `String | null`
239
+
* Default: `null`
240
+
219
241
**Special:** Required when `sourceMap` is a truthy value
220
242
221
243
Specify the intended location of the output file. Strongly recommended when outputting source maps so that they can properly refer back to their intended files.
222
244
223
245
**Attention** enabling this option will **not** write the file on disk for you, it's for internal reference purpose only (to generate the map for example).
Determines the output format of the final CSS style.
249
273
250
274
### precision
251
-
Type: `Integer`
252
-
Default: `5`
275
+
276
+
* Type: `Integer`
277
+
* Default: `5`
253
278
254
279
Used to determine how many digits after the decimal will be allowed. For instance, if you had a decimal number of `1.23456789` and a precision of `5`, the result will be `1.23457` in the final CSS.
255
280
256
281
### sourceComments
257
-
Type: `Boolean`
258
-
Default: `false`
282
+
283
+
* Type: `Boolean`
284
+
* Default: `false`
259
285
260
286
`true` Enables the line number and file where a selector is defined to be emitted into the compiled CSS as a comment. Useful for debugging, especially when using imports and mixins.
261
287
262
288
### sourceMap
263
-
Type: `Boolean | String | undefined`
264
-
Default: `undefined`
289
+
290
+
* Type: `Boolean | String | undefined`
291
+
* Default: `undefined`
292
+
265
293
**Special:** Setting the `sourceMap` option requires also setting the `outFile` option
266
294
267
295
Enables the outputting of a source map during `render` and `renderSync`. When `sourceMap === true`, the value of `outFile` is used as the target output location for the source map. When `typeof sourceMap === "string"`, the value of `sourceMap` will be used as the writing location for the file.
268
296
269
297
### sourceMapContents
270
-
Type: `Boolean`
271
-
Default: `false`
298
+
299
+
* Type: `Boolean`
300
+
* Default: `false`
272
301
273
302
`true` includes the `contents` in the source map information
274
303
275
304
### sourceMapEmbed
276
-
Type: `Boolean`
277
-
Default: `false`
305
+
306
+
* Type: `Boolean`
307
+
* Default: `false`
278
308
279
309
`true` embeds the source map as a data URI
280
310
281
311
### sourceMapRoot
282
-
Type: `String`
283
-
Default: `undefined`
312
+
313
+
* Type: `String`
314
+
* Default: `undefined`
284
315
285
316
the value will be emitted as `sourceRoot` in the source map information
286
317
287
318
## `render` Callback (>= v3.0.0)
319
+
288
320
node-sass supports standard node style asynchronous callbacks with the signature of `function(err, result)`. In error conditions, the `error` argument is populated with the error object. In success conditions, the `result` object is populated with an object describing the result of the render call.
289
321
290
322
### Error Object
323
+
291
324
*`message` (String) - The error message.
292
325
*`line` (Number) - The line number of error.
293
326
*`column` (Number) - The column number of error.
294
327
*`status` (Number) - The status code.
295
328
*`file` (String) - The filename of error. In case `file` option was not set (in favour of `data`), this will reflect the value `stdin`.
296
329
297
330
### Result Object
331
+
298
332
*`css` (Buffer) - The compiled CSS. Write this to a file, or serve it out as needed.
299
333
*`map` (Buffer) - The source map
300
334
*`stats` (Object) - An object containing information about the compile. It contains the following keys:
@@ -359,7 +393,7 @@ var result = sass.renderSync({
359
393
// this.options contains this options hash
360
394
someAsyncFunction(url, prev, function(result){
361
395
done({
362
-
file:result.path, // only one of them is required, see section Sepcial Behaviours.
396
+
file:result.path, // only one of them is required, see section Special Behaviours.
363
397
contents:result.data
364
398
});
365
399
});
@@ -474,6 +508,7 @@ The interface for command-line usage is fairly simplistic at this stage, as seen
474
508
Output will be sent to stdout if the `--output` flag is omitted.
0 commit comments