New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-minify-all

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-minify-all

Minifies CSS, JavaScripts and Images under the current directory tree.

2.0.3
latest
Source
npm
Version published
Weekly downloads
37
-35.09%
Maintainers
1
Weekly downloads
 
Created
Source

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 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.

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. Default all.
  • 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.

API

Use the minify-all-api for this.

var minify = require('node-minify-all/minify-all-api');

var opts = {
	rootpath: 'myfolder',
	mode: 'all',
	backups: false
};

minify.process(opts);

Dependencies

  • gulp
  • imagemin
  • node-minify
  • fs-extra
  • yargs

License

MIT

Keywords

css

FAQs

Package last updated on 21 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts