Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srod/node-minify
Light Node.js module that compress javascript, css and html files
https://github.com/srod/node-minify
babel-minify clean-css cli crass csso gcc google-closure-compiler html html-minifier html5 javascript json minify nodejs sqwish terser uglify-es uglify-js yui yui-compressor
Last synced: 10 days ago
JSON representation
Light Node.js module that compress javascript, css and html files
- Host: GitHub
- URL: https://github.com/srod/node-minify
- Owner: srod
- License: mit
- Created: 2011-06-02T13:43:04.000Z (over 13 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-29T20:29:45.000Z (14 days ago)
- Last Synced: 2024-10-29T22:48:58.347Z (14 days ago)
- Topics: babel-minify, clean-css, cli, crass, csso, gcc, google-closure-compiler, html, html-minifier, html5, javascript, json, minify, nodejs, sqwish, terser, uglify-es, uglify-js, yui, yui-compressor
- Language: TypeScript
- Homepage: https://node-minify.2clics.net
- Size: 56.5 MB
- Stars: 503
- Watchers: 16
- Forks: 53
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
A very light minifier Node.js module.
# Features
It allow you to compress JavaScript, CSS and HTML files.
**JavaScript:**
- [babel-minify](https://node-minify.2clics.net/compressors/babel-minify)
- [Google Closure Compiler](https://node-minify.2clics.net/compressors/gcc)
- [terser](https://node-minify.2clics.net/compressors/terser)
- [uglify-js](https://node-minify.2clics.net/compressors/uglify-js)
- [uglify-es](https://node-minify.2clics.net/compressors/uglify-es)
- [YUI Compressor](https://node-minify.2clics.net/compressors/yui)**CSS:**
- [clean-css](https://node-minify.2clics.net/compressors/clean-css)
- [crass](https://node-minify.2clics.net/compressors/crass)
- [cssnano](https://node-minify.2clics.net/compressors/cssnano)
- [CSSO](https://node-minify.2clics.net/compressors/csso)
- [sqwish](https://node-minify.2clics.net/compressors/sqwish)
- [YUI Compressor](https://node-minify.2clics.net/compressors/yui)**HTML:**
- [html-minifier](https://node-minify.2clics.net/compressors/html-minifier)
**Command Line Interface:**
- [CLI](https://node-minify.2clics.net/cli)
## Installation
```bash
npm install @node-minify/core
# Or Yarn
yarn add @node-minify/core
# Or pnpm
pnpm add @node-minify/core
```And install the compressor you want
```bash
npm install @node-minify/uglify-js
# Or Yarn
yarn add @node-minify/uglify-js
# Or pnpm
pnpm add @node-minify/uglify-js
```## Quick Start
```js
import minify from '@node-minify/core';
import gcc from '@node-minify/google-closure-compiler';
import uglifyjs from '@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' });
}
```### In memory
```js
import htmlMinifier from '@node-minify/html-minifier';const html = `
`;minify({
compressor: htmlMinifier,
content: html
}).then(function (min) {
console.log('html min');
console.log(min);
});
```[More examples](https://github.com/srod/node-minify/blob/master/examples/server.mjs)
## Documentation
Visit https://node-minify.2clics.net for full documentation.
## License
[MIT](LICENSE)