Thursday 27 April 2017

How to concat and minify JS files at once using Grunt

I am using Grunt with 2 plugins: grunt-contrib-uglify and grunt-contrib-concat.

So I have to configure them in grunt.initConfig:

grunt.initConfig({
    concat: {
        dist: {
            src: 'src/scripts/**/*.js',
            dest: 'dist/global.js'
        }
    }
    uglify: {
       build: {
          src: 'dist/global.js',
          dest: 'dist/global.min.js'
       }
    }
});

With this code I am creating a file global.js in dist folder and then uglifying it. But I don't need this file at all! I need only global.min.js.

Is there a way to assign the result of concat task to some variable and use uglify on it without creating unwanted files?



via CMTV

No comments:

Post a Comment