1 | # Examples
|
2 |
|
3 | ## Example config
|
4 |
|
5 | ```javascript
|
6 | grunt.initConfig({
|
7 | sass: { // Task
|
8 | dist: { // Target
|
9 | options: { // Target options
|
10 | style: 'expanded'
|
11 | },
|
12 | files: { // Dictionary of files
|
13 | 'main.css': 'main.scss', // 'destination': 'source'
|
14 | 'widgets.css': 'widgets.scss'
|
15 | }
|
16 | }
|
17 | }
|
18 | });
|
19 |
|
20 | grunt.loadNpmTasks('grunt-contrib-sass');
|
21 |
|
22 | grunt.registerTask('default', ['sass']);
|
23 | ```
|
24 |
|
25 | ## Compile
|
26 |
|
27 | ```javascript
|
28 | grunt.initConfig({
|
29 | sass: {
|
30 | dist: {
|
31 | files: {
|
32 | 'main.css': 'main.scss'
|
33 | }
|
34 | }
|
35 | }
|
36 | });
|
37 | ```
|
38 |
|
39 | ## Concat and compile
|
40 |
|
41 | Instead of concatenating the files, just `@import` them into another `.sass` file eg. `main.scss`.
|
42 |
|
43 |
|
44 | ## Compile multiple files
|
45 |
|
46 | You can specify multiple `destination: source` items in `files`.
|
47 |
|
48 | ```javascript
|
49 | grunt.initConfig({
|
50 | sass: {
|
51 | dist: {
|
52 | files: {
|
53 | 'main.css': 'main.scss',
|
54 | 'widgets.css': 'widgets.scss'
|
55 | }
|
56 | }
|
57 | }
|
58 | });
|
59 | ```
|
60 |
|
61 | ## Compile files in a directory
|
62 |
|
63 | Instead of naming all files you want to compile, you can use the `expand` property allowing you to specify a directory. More information available in the [grunt docs](http://gruntjs.com/configuring-tasks) - `Building the files object dynamically`.
|
64 |
|
65 | ```javascript
|
66 | grunt.initConfig({
|
67 | sass: {
|
68 | dist: {
|
69 | files: [{
|
70 | expand: true,
|
71 | cwd: 'styles',
|
72 | src: ['*.scss'],
|
73 | dest: '../public',
|
74 | ext: '.css'
|
75 | }]
|
76 | }
|
77 | }
|
78 | });
|
79 | ```
|