Throughout the course of my project development I wish to combine JS and CSS files into global.js and global.css files and then minify them into global.min.js and global.min.css using gruntjs and use these minified files in my project.
But everytime I run the commands it cancats/combines the files and adds the combined codes to the global files(Causing redundancy) instead of replacing those global files with the new combined codes. Is there any option for it or any other plugin to prevent that?
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: [
'js/**/*.js',
'js/*.js'
],
dest: 'js/global.js',
}
},
uglify: {
build: {
src: 'js/global.js',
dest: 'js/global.min.js'
}
},
cssmin: {
combine: {
files: {
'css/global.css': ['css/*.css','css/**/*.css']
}
},
minify: {
src: 'css/global.css',
dest: 'css/global.min.css'
}
},
});
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'uglify', 'cssmin']);
};