node-minify-all
Minifies CSS, JavaScripts and Images under the current directory tree with gulp task wrapper.
What's new?
- 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.
- We had this requirement of minifying and compressing artefacts before theme and portlet build in Liferay. Since somehow Liferay does not automatically minify all these files before compiling and building, we had to manually trigger the minification process prior to build. This module is used in that build process by Jenkins job and pipeline.
Usage
Using gulp
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 myfolderMinifies all the CSS files under the directory .
$ gulp minify-js --backups trueMinifies all the JavaScript files under the directory .
$ gulp minify-img --rootpath=myfolder --backups=trueMinifies all the image files under the directory .
$ gulp Runs all the above three tasks, minifiying all images, CSS and JS files.
Using node cli
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=cssMinifies all the CSS files under the directory .
$ node index --rootpath myfolder --mode js --backups trueMinifies all the JavaScript files under the directory .
$ node index --rootpath=myfolder --mode=img --backups=trueMinifies all the image files under the directory .
$ node index --rootpath myfolder --backups trueRuns all the above three tasks, minifiying all images, CSS and JS files.
API
Use the minify-all-api
for this.
var minify = ; var opts = rootpath: 'myfolder' mode: 'all' backups: false; minify;
Dependencies
License
MIT