1

This is my gruntfile.js

module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.initConfig({
uglify:{
my_target: {
files:{
'_/js/script.js': ['_/components/js/*.js']      
}//files
}//myTarget
},//uglify
compass: {
dev:{
options: {
config: 'config.rb',                    
}//options
}//dev
},//compass
watch: {
options: {livereload: true},
scripts: {
files: ['_/components/js/*.js'],
tasks: ['uglify']       
},//scripts     
html: {
files: ['*.html']
},//html
sass: {
files: ['_/components/sass/*.scss']
tasks: ['compass:dev']
},//sass  
}//watch
})//initConfig
grunt.registerTask('default','watch'); 
}//exports

Running grunt in Command Prompt gives ERROR: Loading "gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected identifier Warning: Task "default" not found. Use --force to continue.

When I comment out SASS block (in gruntfile.js)... then grunt says: Running "watch" task Waiting ... and everything is working fine!

Does anyone know what could be a problem?

2 Answers 2

2

To me there just seemed to be a few simple typo's, missing ,'s etc Also, try register a task like this:

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

here is a tidied up version, hopefully this works for you.

module.exports = function(grunt) {

    grunt.initConfig({
        uglify: {
            my_target: {
                files: {
                    '_/js/script.js': ['_/components/js/*.js']
                } //files
            } //myTarget
        }, //uglify
        compass: {
            dev: {
                options: {
                    config: 'config.rb'
                } //options
            } //dev
        }, //compass
        watch: {
            options: {
                livereload: true
            },
            scripts: {
                files: ['_/components/js/*.js'],
                tasks: ['uglify']
            }, //scripts     
            html: {
                files: ['*.html']
            }, //html
            sass: {
                files: ['_/components/sass/*.scss'],
                tasks: ['compass:dev']
            } //sass  
        } //watch
    }); 
    //initConfig
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['watch']);
} //exports
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you very much, your suggestion helped ... grunt is Running "Watch" task and Waiting ... but when I change something in styles.scss, and save I get this: Running "watch" task Waiting... >> File "_\components\sass\styles.scss" changed. Warning: Task "compass:dev" not found. Use --force to continue. Aborted due to warnings. Completed in 1.753s at Thu Feb 05 2015 14:27:39 GMT+0100 (W. Europe Standard Tim e) - Waiting...
Great, if the answer helped answer your question, you can accept it by clicking the big tick so others know what solution worked. If you are still having a problem, please provide details, thanks
you are calling ['compass:dev'] in the watch task, but you havent loaded the compass plugin. you need to install and load the "compass" plugin with: grunt.loadNpmTasks('grunt-contrib-compass'); or whatever compass plugin you are using
That solved the problem ... everything is working as it should!!! Thanx again for your help. And I accepted your answer by clicking the big tick! :) (sorry I didn't do it in the first place, I'm new here)
glad it worked, I didnt know how the tick and upvote worked when I first started either, thats why I thought I'd mention it.
0

My reason is that I download the zip file, and the zip files do not contain the source files, only the built files, so there is no need for grunt tasks. I use git clone to clone the source file, solved this issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.