0

I have a folder with differents design project, on each one I may have scss files to compile. So I did a Gruntfile to watch on all this folders for the scss files and I want to compile them in their directory. But it' actually not working because of this error :

Running "sassAll" task

Running "sass:animating-rocket" (sass) task
Verifying property sass.animating-rocket exists in config...ERROR
>> Unable to process task.
Warning: Required config property "sass.animating-rocket" missing. Use --force to continue.

Aborted due to warnings.

It seems that a variable is not define on the config scope...

My Gruntfile looks like this :

module.exports = function (grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        sass: {
            dist: {
                options: {
                    style: 'compressed'
                },
                files: [{
                    src: ['<%= grunt.task.current.args[0] %>/*.scss'],
                    dest: '<%= grunt.task.current.args[0] %>',
                    ext: '.css'
                }]
            }
        },

        watch: {
            options: {
                livereload: true
            },

            css: {
                files: ['**/*.scss'],
                tasks: ['sassAll'],
                options: {
                    spawn: false
                }
            }
        }

    });

    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('sassAll', function () {
        gruntUtils.sassTasks.forEach(function (param) {
            grunt.task.run('sass:' + param);
        });
    });

    var gruntUtils = {
        sassTasks: ['animating-rocket', 'hamburger-animation']
    };

    grunt.registerTask('default', ['sassAll', 'watch']);

};
Hugo
  • 163
  • 4
  • 16
  • If am not wrong, I believe grunt is trying to run the task called 'animating-rocket' under 'sass' config, since it couldn't find any task named 'animating-rocket' it is throwing error – Gopinath Shiva Aug 09 '16 at 08:41
  • @GopinathShiva I'm agree with you but I don't understand why Grunt try to run this task ? I juste want to run the sass task with 'animating-rocket' as parameter. – Hugo Aug 09 '16 at 08:53
  • I believe your way of creating task using param is wrong. Reference: http://stackoverflow.com/questions/18623739/pass-options-to-a-grunt-task-while-running-it – Gopinath Shiva Aug 09 '16 at 08:57
  • I read this topic yet but I don't see how to use the params in this part of my code : `files: [{ src: ['<%= grunt.task.current.args[0] %>/*.scss'], dest: '<%= grunt.task.current.args[0] %>', ext: '.css' }]` – Hugo Aug 09 '16 at 09:41
  • My ultimate goal is to be able to watch on any modifications of a scss files and to recompile it. But the thing is that on each folder it's a different project. – Hugo Aug 09 '16 at 14:13

0 Answers0