Error trying to minify js files in grunt

0

When I run the grunt uglify command this error appears.

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

File 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");  
}
    
asked by anonymous 27.10.2017 / 03:27

2 answers

1

It's missing you registering the uglify task, try something like:

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

Then in cmd type grunt u

    
03.01.2018 / 18:38
0

I do not see anything wrong in the configuration, and I put the path and the folders according to your application, I made an example only with uglify , because it seemed to me that the error is in it, 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'
        }]
     }
  }
    
27.10.2017 / 17:40