7

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?

Mekajiki
  • 911
  • 2
  • 8
  • 18

1 Answers1

24

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.

pkk
  • 3,691
  • 2
  • 21
  • 29
Jesús Quintana
  • 1,803
  • 13
  • 18
  • 1
    OMG, my mistake was typo "expand" with "expnad", thank you very much. – Mekajiki Nov 20 '13 at 08:50
  • Make sure you don't add a `/` before `sass/folder` or before `dest/folder`. For some reason it breaks it. That was issue I was having. – Jon Doe Dec 27 '16 at 17:31