Reputation: 245
I have added the Sass task to my grunt process using the grunt-contrib-sass plugin. Here is my gruntfile:
module.exports = function ( grunt ) {
grunt.loadNpmTasks('grunt-contrib-sass');
/**
* Load in our build configuration file.
*/
var userConfig = require( './build.config.js' );
/**
* This is the configuration object Grunt uses to give each plugin its
* instructions.
*/
var taskConfig = {
/**
* We read in our `package.json` file so we can access the package name and
* version. It's already there, so we don't repeat ourselves here.
*/
pkg: grunt.file.readJSON("package.json"),
sass: {
dev: {
files: [{
expand: true,
cwd: 'css',
src: ['**/*.scss'],
dest: 'css',
ext: '.css'
}]
},
prod: {
files: [{
expand: false,
cwd: 'css',
src: ['**/*.scss'],
dest: 'css',
ext: '.css'
}]
}
},
};
grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );
grunt.registerTask('default', [ 'sass:prod' ]);
grunt.registerTask('dev-build', [ 'sass']);
grunt.registerTask('sass', [ 'sass:dev' ]);
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});
};
I have Ruby 1.9.3 and the Sass Gem 3.3.2 installed and working from the command line and IntelliJ 13. But when I try to run grunt sass or apply a grunt watch to my scss files, I get the following trace output:
<c:\users\[proj_dir_path]>grunt sass --verbose
Initializing
Command-line options: --verbose
Reading "gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Registering "grunt-contrib-sass" local Npm module tasks.
Reading C:\Users\[proj_path]\node_modules\grunt-contrib-sass\package.json...OK
Parsing C:\Users\[proj_path]\node_modules\grunt-contrib-sass\package.json...OK
Loading "sass.js" tasks...OK
+ sass
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "gruntfile.js" tasks...OK
+ sass
Running tasks: sass
Running "sass" task
[About 500 more repeats of this]
Running "sass" task
Warning: Maximum call stack size exceeded Use --force to continue.
Aborted due to warnings.
To run the SCSS Gem, I have to execute the scss.bat command with the arguments. My best guess is that the Grunt Sass plugin is trying to execute the Ruby EXE with arguments while on my system I have to run it with the the bat. This is just my guess combing through the sass.js Task code. Has anyone else had a similar issues and is there any workaround or solve for this?
Upvotes: 1
Views: 3381
Reputation: 3331
I think it is a recursion problem, the registered task is running itself in a loop.
mine works without
grunt.registerTask('sass', [ 'sass:dev' ]);
as it appears anything set in the initConfig is automatically a task. If removing that line doesn't work try renaming it
grunt.registerTask('my-sass', [ 'sass:dev' ]);
and running
grunt my-sass
Upvotes: 4
Reputation: 17203
Try changing -
grunt.registerTask('sass', [ 'sass' ]);
to
grunt.registerTask('sass', [ 'sass:dev' ]);
or
grunt.registerTask('sass', [ 'sass:prod' ]);
Upvotes: 0