0
votes

I try to added the Sass task to my grunt process using the grunt-contrib-sass plugin but when i run it he create the css files but this file is empty

This is my Gruntfile.js :

module.exports = function(grunt){
grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: {
            dist: {
                options: {
                    style:'expanded',
                    trace: true
                },

                files: {
                    'main.css':'sass/app.scss'
                }
            }
        },

        watch: {
            css: {
                files: '**/*.scss',
                tasks: ['sass']
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default', ['watch']);
};

When i start the command "grunt" i have this :

Running "watch" task
Waiting.....
File "sass\app.scss" changed
Running "sass:dist" task
(and nothing)

I have :

  • Ruby 2.1.5 [x64-mingw32]
  • SASS : 3.4.10
  • Grunt : newest version

Thanks !

1
Could you post your sass/app.scss file?Adrien Cadet
@JanickBernet Nothing very advanced, I just put a rule in another : .coco { margin: 2px; h1 { margin: 5px; } }user4489673
Can you tell us your folder structure? I think its something to do with the path "sass/app.scss". See that the file location is correct relative to the gruntfile location.Sharat M R
I have some trouble to make a line break so here a link for the image of the folder structure : link as you can see when i start the command "grunt" the files main.css is created but he just dont compile the instruction from app.scss into main.cssuser4489673

1 Answers

0
votes

Could you try changing this:

watch: { css: files: '**/*.scss', tasks: ['sass'] } }

To this:

watch: { css: files: '/**/*.scss', tasks: ['sass'] } }

To make sure it watches from the root of the project