Gruntjs concat & minify | Ability to replace code in the target file instead of adding

During the development of my project, I would like to combine the JS and CSS files into the global.js and global.css files and then instruct them in global.min.js and global.min.css using gruntjs and use these miniature files in my project .

But each time I run commands, it can / combines files and adds combined codes to global files (causing redundancy) instead of replacing these global files with new combined codes. Is there any option for it or any other plugin to prevent this?

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']); }; 
0
source share
1 answer

Create merged and reduced files in a separate directory for the files from which they are made.

+2
source

Source: https://habr.com/ru/post/1204336/


All Articles