Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snigbhaumik/node-minify-all
Minifies CSS, JavaScripts and Images under the current directory tree
https://github.com/snigbhaumik/node-minify-all
css-minifier gulp jenkins jenkins-build jenkins-pipeline js-minifier liferay liferay-portal minifies-css node-minify
Last synced: 3 months ago
JSON representation
Minifies CSS, JavaScripts and Images under the current directory tree
- Host: GitHub
- URL: https://github.com/snigbhaumik/node-minify-all
- Owner: SnigBhaumik
- License: mit
- Created: 2017-06-15T11:47:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-19T10:02:28.000Z (over 7 years ago)
- Last Synced: 2024-11-15T20:59:24.141Z (3 months ago)
- Topics: css-minifier, gulp, jenkins, jenkins-build, jenkins-pipeline, js-minifier, liferay, liferay-portal, minifies-css, node-minify
- Language: JavaScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```sh
$ gulp minify-css --rootpath myfolder
Minifies all the CSS files under the directory (files with .css extension).
```
```sh
$ gulp minify-js --backups true
Minifies all the JavaScript files under the directory (files with .js extension).
```
```sh
$ gulp minify-img --rootpath=myfolder --backups=true
Minifies all the image files under the directory (files with .jpg and .png extension).
```
```sh
$ 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`.
```sh
$ node index --rootpath=myfolder --mode=css
Minifies all the CSS files under the directory (files with .css extension).
```
```sh
$ node index --rootpath myfolder --mode js --backups true
Minifies all the JavaScript files under the directory (files with .js extension).
```
```sh
$ node index --rootpath=myfolder --mode=img --backups=true
Minifies all the image files under the directory (files with .jpg and .png extension).
```
```sh
$ 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.
```js
var minify = require('node-minify-all/minify-all-api');var opts = {
rootpath: 'myfolder',
mode: 'all',
backups: false
};minify.process(opts);
```# Dependencies
- [gulp](https://www.npmjs.com/package/gulp)
- [imagemin](https://www.npmjs.com/package/imagemin)
- [node-minify](https://www.npmjs.com/package/node-minify)
- [fs-extra](https://www.npmjs.com/package/fs-extra)
- [yargs](https://www.npmjs.com/package/yargs)# License
MIT