0

i have this tasks in gruntfile.js

and when I run: grunt default Loading "gruntfile.js" tasks...ERROR

SyntaxError: Unexpected token : Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

i don't find where is the error in my code.

module.exports = function (grunt) {
  // Project configuration.
  grunt.initConfig({
    //uglify
    uglify: {
      options: {
        mangle: false,
        compress: {
          drop_console: true
        }
      },
      js: {
        files: [{
          cwd: 'assets/javascripts/',
          expand: true,
          src: '*.js',
          dest: 'assets/javascripts/min/'
        }]
      }
    }
 });


  sass: {
        // this is the "dev" Sass config used with "grunt watch" command
        dev: {
            options: {
                style: 'expanded',
                // tell Sass to look in the Bootstrap stylesheets directory when compiling
                loadPath: 'assets/stylesheets/sass/'
            },
            files: {
                // the first path is the output and the second is the input
                'sass/main.css': 'assets/styleheets/sass/main.scss'
            }
        },
        // this is the "production" Sass config used with the "grunt buildcss" command
        dist: {
            options: {
                style: 'compressed',
                loadPath: 'assets/stylesheets'
            },
            files: {
                'sass/main.css': 'assets/stylesheets/sass/main.scss'
            }
        }
    },
    // configure the "grunt watch" task
    watch: {
        sass: {
            files: 'sass/*.scss',
            tasks: ['sass:dev']
        }
    }
});
 // loadNpmTasks
 grunt.loadNpmTasks('grunt-contrib-uglify');
 grunt.loadNpmTasks('grunt-contrib-sass');
 grunt.loadNpmTasks('grunt-contrib-watch');

 // Run Default task(s).
grunt.registerTask('default', ['uglify', 'watch', 'buildcss']);
};

1 Answer 1

0

Your definitions are not nested properly, you should move sass and watch inside the grunt.initConfig block, and move grunt.registerTask, grunt.loadNpmTasks directives to the end of the function(grunt) {} block, like that:

module.exports = function (grunt) {
    grunt.initConfig({
         uglify: {},
         sass : {},
         watch : {}
    });

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

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

see Sample Gruntfile

Sign up to request clarification or add additional context in comments.

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.