Search code examples
javascriptangularjsgruntjsuglifyjsgrunt-contrib-concat

How to skip concat in grunt build


I need to skip the concat on the grunt build, cause it cause me lot of error, and conflicts in my angular project.

I tried this on my Gruntfile.js :

copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '*.html',
            'images/{,*/}*.{webp}',
            'styles/fonts/{,*/}*.*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        },{
          expand: true,
          cwd: '.tmp/scripts',
          dest: '<%= yeoman.dist %>/scripts',
          src: ['<%= yeoman.app %>/scripts/{,*/}*.js']
        }, {
          expand: true,
          cwd: 'bower_components/bootstrap/dist',
          src: 'fonts/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'postcss',
    'ngtemplates',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin'
  ]);

But still give me an output of concat scripts uglify.


Solution

  • Create your own task witch will run ngAnnotate then uglify and cssmin for minifying css.

    You can also specify your js files that you want to uglify and annotate on the grunt.initConfig:

    ngAnnotate : {
        dist: {
            files: {
                '.tmp/scripts/MYFILE.min.js' : ['app/scripts/MYFILE.js'],
                 /*...*/
    

    It's a lower version, and more static of grunt build, but it would doing a minification and annotation of you project.