Minifies CSS, JavaScripts and Images under the current directory tree with gulp task wrapper.
- Of course, lots of image, js, css minifiers are available around. The difference is here we can write individual business rules per file (for example, in case you don't want a particular file not to be minified).
- You can run individual tasks or all the tasks or any combination of these.
You can pass two command line arguments (both optional).
- rootpath: name of the folder under current directory, where the process should execute. Default
docroot. - backups: boolean value to determine whether backup copy should be created while minifying. Default
false.
Four gulp tasks are defined.
$ gulp minify-css --rootpath myfolder Minifies all the CSS files under the directory (files with .css extension).$ gulp minify-js --backups true Minifies all the JavaScript files under the directory (files with .js extension).$ gulp minify-img --rootpath=myfolder --backups=true Minifies all the image files under the directory (files with .jpg and .png extension).$ gulp Runs all the above three tasks, minifiying all images, CSS and JS files.You can pass three command line arguments (all optional).
- rootpath: name of the folder under current directory, where the process should execute. Default
docroot. - mode: what should be minified. Options are
css,js,img,all. Defaultall. - backups: boolean value to determine whether backup copy should be created while minifying. Default
false.
$ node index --rootpath=myfolder --mode=css Minifies all the CSS files under the directory (files with .css extension).$ node index --rootpath myfolder --mode js --backups true Minifies all the JavaScript files under the directory (files with .js extension).$ node index --rootpath=myfolder --mode=img --backups=true Minifies all the image files under the directory (files with .jpg and .png extension).$ node index --rootpath myfolder --backups true Runs all the above three tasks, minifiying all images, CSS and JS files.MIT