GithubHelp home page GithubHelp logo

isabella232 / node-minify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lumakernel/node-minify

0.0 0.0 0.0 52.66 MB

Light Node.js module that compress javascript, css and html files

Home Page: https://node-minify.2clics.net

License: MIT License

JavaScript 100.00%

node-minify's Introduction

node-minify

A very light minifier Node.js module.


Build Status

Features

It allow you to compress JavaScript, CSS and HTML files.

JavaScript:

CSS:

HTML:

Command Line Interface:

Installation

npm install @node-minify/core # OR yarn add @node-minify/core

And install the compressor you want

npm install @node-minify/uglify-js # OR yarn add @node-minify/uglify-js

Quick Start

const minify = require('@node-minify/core');
const gcc = require('@node-minify/google-closure-compiler');
const uglifyjs = require('@node-minify/uglify-js');

// Using Google Closure Compiler
minify({
  compressor: gcc,
  input: 'foo.js',
  output: 'bar.js',
  callback: function(err, min) {}
});

// Using UglifyJS
minify({
  compressor: uglifyjs,
  input: './**/*.js',
  output: 'bar.js',
  callback: function(err, min) {}
});

// Using Promise
var promise = minify({
  compressor: uglifyjs,
  input: './**/*.js',
  output: 'bar.js'
});

promise.then(function(min) {});

// Async/Await
async function doMinify() {
  const min = await minify({ compressor: uglifyjs, input: 'foo.js', output: 'bar.js' });
}

ES2015+

import minify from '@node-minify/core';
import gcc from '@node-minify/google-closure-compiler';

minify({
  compressor: gcc,
  input: 'foo.js',
  output: 'bar.js',
  callback: function(err, min) {}
});

In memory

const htmlMinifier = require('@node-minify/html-minifier');

const html = `
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
    </head>
</html>`;

minify({
  compressor: htmlMinifier,
  content: html
}).then(function(min) {
  console.log('html min');
  console.log(min);
});

More examples

Documentation

Visit https://node-minify.2clics.net for full documentation.

License

MIT

node-minify's People

Contributors

srod avatar dependabot-preview[bot] avatar mergify[bot] avatar greenkeeper[bot] avatar dependabot-support avatar greenkeeperio-bot avatar sebbo2002 avatar zhangmx avatar brianberlin avatar chrispecoraro avatar mathiasbynens avatar alexbardas avatar indatawetrust avatar arnog avatar dsego avatar icoloma avatar stefanoortisi avatar tedgrubb avatar azure-pipelines[bot] avatar dependabot[bot] avatar mandarnaik016 avatar sasha0552 avatar snyk-bot avatar

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.