Giter VIP home page Giter VIP logo

node-minify-all's Introduction

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

License

MIT

node-minify-all's People

Stargazers

 avatar

Watchers

 avatar  avatar

node-minify-all's Issues

build error

Hi,

in unix we get this error
doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✔ pngquant pre-build test passed successfully
✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.