Skip to content

Commit

Permalink
added config option
Browse files Browse the repository at this point in the history
- Added the option to set the sass and css folders in the grunt config
file so you don't have to create a separate compass configuration file
- updated the read me to reflect these changes
  • Loading branch information
ronaldlokers committed Jun 2, 2012
1 parent 0b53a2f commit 797a17d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
36 changes: 28 additions & 8 deletions README.md
Expand Up @@ -5,11 +5,31 @@ This is a custom grunt.js task that executes `compass compile` for you and print
1. Place the `grunt-compass` folder in the root of your project.
2. Call `grunt.loadTasks('grunt-compass/tasks');` in your gruntfile.
3. Configure `grunt watch` to watch your scss files and call the task.
e.g.:

````javascript
watch: {
files: ['assets/scss/partials/*.scss'],
tasks: ['compass']
}
````
e.g.:

```javascript
watch: {
files: ['assets/scss/partials/*.scss'],
tasks: ['compass']
}
```

4. Setup the config for compass in your grunt config, or setup a compass config file:
* Option 1: Set the configuration for compass in your grunt.js file:

```javascript
compass: {
src: 'assets/scss/partials',
dest: 'assets/css/partials'
}
```

"src" is the folder with sass/scss files.
"dest" is the file where the css files will be place.
* Option 2: Setup a compass project
```
compass install compass
```
5. Run "grunt watch" and change some SASS files :)

**Notice:** At this moment this task doesn't work with "grunt" or "grunt compass" it only creates the folders, not the files!
16 changes: 11 additions & 5 deletions tasks/grunt-compass.js
Expand Up @@ -3,22 +3,28 @@ module.exports = function( grunt ) {
// Create a new task.
grunt.registerTask( 'compass', 'This triggers the `compass compile` command.', function() {

var exec = require('child_process').exec;
grunt.log.write( '`compass compile` was initiated.' );
var exec = require('child_process').exec,
command = "compass compile",
src = grunt.config('compass.src'),
dest = grunt.config('compass.dest');

if (src !== undefined &&
dest !== undefined) {
command += ' --sass-dir="' + src + '" --css-dir="' + dest + '"';
}

function puts( error, stdout, stderr ) {

grunt.log.write( '\n\nCOMPASS output:\n' );
grunt.log.write( stdout );
grunt.log.error( stderr );



if ( error !== null ) {
grunt.log.error( error );
}
}

exec( "compass compile", puts );
exec( command, puts );
grunt.log.write( '`' + command + '` was initiated.' );
});
};

0 comments on commit 797a17d

Please sign in to comment.