Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt file fails 'Aborted due to warnings'

Tags:

sass

gruntjs

I'm new to Grunt. I thought I'd give it a try, so I created this grunt file.

module.exports = function(grunt) {

    grunt.initConfig({

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

        concat: {
            css: {
                src: [
                    './css/*'
                ],
                dest: './css/all.css'
            },
            js: {
                src: [
                    './js/*'
                ],
                dest: './js/all.js'
            }
        },

        uglify: {
            js: {
                files: {
                    './js/build/all.min.js': ['./js/all.js']
                }
            }
        },

        sass: {
            build: {
                files: [{
                    expand: true,
                    cwd: './css/sass',
                    src: ['*.scss'],
                    dest: './css',
                    ext: '.css'
                }]
            }
        },

        cssmin: {
            css: {
                src: './css/all.css',
                dest: './css/build/all.min.css'
            }
        },

        watch: {
            files: ['./css/sass/*', './js/*'],
            tasks: ['sass:build','concat:css', 'cssmin:css', 'concat:js', 'uglify:js']
        }

    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-concat');

    grunt.registerTask('dev', ['sass:build','concat:css', 'cssmin:css', 'concat:js', 'uglify:js']);

};

When I run 'grunt watch' and make a change to an .scss file, terminal complains and then aborts.

Running "watch" task
Waiting...
>> File "css/sass/all.scss" changed.
Running "sass:build" (sass) task
File css/all.css created.

Running "concat:css" (concat) task
Warning: Unable to read "./css/build" file (Error code: EISDIR). Use --force to continue.

Aborted due to warnings.
Completed in 1.276s at Thu May 01 2014 23:53:59 GMT+0100 (BST) - Waiting...

Please can someone point out where I'm going wrong?

It looks to be with the concat:css - but there's no reference to the build directory there.

I believe it may be because certain tasks are colliding and files aren't ready yet to be worked with perhaps? Is there an order to tasks?

Please bear with me as it's all new!

Thanks, Michael.

like image 428
Michael Giovanni Pumo Avatar asked May 01 '14 22:05

Michael Giovanni Pumo


2 Answers

I notice this is quite old, but I'll add an answer for posterity.

This was happening to me because of a missing variable in the SASS file.

Try adding "--force" onto your grunt command. The build will still fail, but you will probably get a more helpful error message.

like image 97
sammysounder Avatar answered Oct 20 '22 06:10

sammysounder


try to add the nospawn: true option into de the sass task options.

Also if you want to have a more complete error response you could run grunt --verbose

like image 21
Santiago Rebella Avatar answered Oct 20 '22 06:10

Santiago Rebella