How to configure Grunt's recursive Sass compilation task

I am new and learn how to set up coffee, jade and sass compilation tasks. I could successfully configure compilation tasks for the coffee and jade catalog, but I could not do this. The structure of my project is below.

. β”œβ”€β”€ Gruntfile.coffee β”œβ”€β”€ node_modules β”œβ”€β”€ package.json β”œβ”€β”€ sass β”‚  └── index.sass └── www 

and my .json package

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

when Gruntfile.coffee is lower, $ grunt sass compile index.css is successful:

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

but if below, β†’ The source file "index.sass" was not found. error displayed

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

How can I set up a recursive sass compilation task?

+7
sass coffeescript gruntjs
source share
1 answer

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 the launch directory, src is the regular expression for matching ** (in the folder), dest is the folder where it is stored after compilation, and finally ext added

This should work for all tasks that use files to grumble.

+23
source share

All Articles