Error trying to minify js files in Grunt

Asked

Viewed 79 times

0

When I execute the command Grunt uglify this error appears.

Loading "gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "uglify" not found. Use --force to continue.
Aborted due to warnings.

Filing cabinet gruntfile.js

module.exports = function (grunt) {
grunt.initConfig({
    uglify: {
        dist: {
          files: {
            'dist/main.min.js': ["js/*.js"]
          }
        }
    },
    cssmin : {//task
        dist : {//targ
            files : {//configurações
                "dist/css/style.min.css" : ["css/*.css"]
            }
        }
    },
    watch : {
        dist : {//targ
            files : ["css/*.css"]
            tasks : ["cssmin"]
        }
    }
});
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-watch");  
}
  • Hello, how is your package.json?

2 answers

1

Missing you record the uglify task, try something like:

grunt.registerTask('u', ['uglify']);

So in cmd type grunt u

0

I do not see something wrong in the configuration, and put of the path and the folders conforms your application, I made an example with only the uglify, because it seemed to me that it is in him the mistake, try to use this way:

uglify: {
     options: {
        mangle: false
     },
     my_target: {
        files: [{
           expand: true,
           cwd: 'assets/_js',
           src: '**/*.js',
           dest: 'assets/js/',
           ext: '.min.js'
        }]
     }
  }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.