0

I have a Gruntfile.js setup as basic as it goes. It's creating the minified default file yet I'm receiving errors during running grunt task.

>>No "uglify" targets found.

Gruntfile.js

EDITED uglify out of concat.

'use strict';
module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            options: {
                separator: '\n'
            },
            dist: {
                src: ['node_modules/angular/angular.js', 'assets/js/modules/default.js'],
                dest: 'assets/js/dist/main.js'
            }
        },
            uglify: {
                options: {
                    banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */'+"\n"
                },
                    files: {
                        'assets/default.min.js': ['<%= concat.dist.dest %>']

                }
            }

    });
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.registerTask('default', ['concat', 'uglify']);
};

Please let me know what i'm doing wrong, thanks! Bud.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
erezT
  • 186
  • 17
  • Does `assets/default.min.js` exist? – evolutionxbox May 17 '17 at 08:42
  • I'm not sure what you are trying to do with the uglify task into the concat. They are 2 different packages and they should define at the same level, [example here](http://stackoverflow.com/questions/22544649/why-is-it-recommended-to-use-concat-then-uglify-when-the-latter-can-do-both) – Erwan Haquet May 17 '17 at 08:42
  • your are totally right, I took uglify out of concat, now i'm getting no errors yet no default.min.js file is being created from uglify. – erezT May 17 '17 at 08:50
  • i give you my grunt configuration for those 2 tasks in reply, they are very simple but you can adjust with your needs. – Erwan Haquet May 17 '17 at 08:56
  • @ErwanHaquet sure, thanks. I am supposed to put in more tasks but for some god forsaken reason I got stuck on uglify, shame.. – erezT May 17 '17 at 09:02

1 Answers1

1

This is my simplified gruntfile, with just the necessary.

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            dist: {
                src: ['app/Resources/app/src/*.js', 'app/Resources/app/src/**/*.js'],
                dest: 'web/app/js/app.js'
            }
        },
        uglify: {
            app: {
                src: ['web/app/js/app.js'],
                dest: 'web/app/js/app-min.js'
            }
        }
    });
    grunt.registerTask('default', ['concat', 'uglify']);
};

hope it helps :)

Erwan Haquet
  • 263
  • 1
  • 11