Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure directory-recursive Sass compilation task by Grunt

I'm a newbie and learning how to configure coffee, jade, and sass compilation tasks. I could successfully configure compilation tasks for coffee and jade directory but I couldn't for sass. The structure of my project is bellow

.                                                                                                   
├── Gruntfile.coffee                                                                                
├── node_modules                                                                                    
├── package.json                                                                                    
├── sass                                                                                            
│   └── index.sass                                                                                  
└── www

and my package.json is

{
  "name": "grunt-sass-test",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-sass": "~0.5.0"
  }
}

when Gruntfile.coffee is bellow, $ grunt sass compile index.css successfully:

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')
    sass:
      compile:
        files:[
          "www/index.css": "sass/index.sass"
        ]

but when as bellow, >> Source file "index.sass" not found. error is shown

    sass:
      compile:
        cwd: 'sass'
        src: ['**/*.sass']
        dest: 'www/'
        ext: '.css'

How can I configure recursive sass compilation task?

like image 262
Mekajiki Avatar asked Nov 07 '13 00:11

Mekajiki


1 Answers

In grunt all recursive files work the same way:

files: [{
  expand: true,
  cwd: "sass/folder",
  src: ["**/*.sass"],
  dest: "dest/folder",
  ext: ".css"
}]

expand is for doing recursive, cwd is startup directory, src is regex to match ** (in folder), dest is the folder where it saves after being compiled, and finally ext is the extension added

This should work for all tasks which use files, in grunt.

like image 128
Jesús Quintana Avatar answered Sep 28 '22 10:09

Jesús Quintana