add build
This commit is contained in:
1009
node_modules/minify/ChangeLog
generated
vendored
Normal file
1009
node_modules/minify/ChangeLog
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
114
node_modules/minify/HELP.md
generated
vendored
Normal file
114
node_modules/minify/HELP.md
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
Minify
|
||||
===============
|
||||
[NPM_INFO_IMG]: https://nodei.co/npm/minify.png?stars
|
||||
|
||||
[Minify](http://coderaiser.github.io/minify "Minify") - a minifier of js, css, html and img files,
|
||||
used in [Cloud Commander](http://cloudcmd.io "Cloud Commander") project.
|
||||
|
||||
To use `minify` as middleware try [Mollify](https://github.com/coderaiser/node-mollify "Mollify").
|
||||
|
||||
Install
|
||||
---------------
|
||||
![NPM_INFO][NPM_INFO_IMG]
|
||||
|
||||
You can install minify via [npm](https://www.npmjs.org/):
|
||||
|
||||
```
|
||||
npm i minify -g
|
||||
```
|
||||
|
||||
Command Line
|
||||
---------------
|
||||
Command line syntax:
|
||||
|
||||
```
|
||||
minify <input-file1> <input-file2> <input-fileN> > output
|
||||
stdout | minify --<flag>
|
||||
```
|
||||
For example:
|
||||
|
||||
```
|
||||
minify client.js util.js > all.js
|
||||
minify screen.css reset.css > all.css
|
||||
|
||||
cat client.js | minify --js
|
||||
cat *.css | minify --css
|
||||
```
|
||||
|
||||
API
|
||||
---------------
|
||||
The **Minify** module contains an api for interacting with other js files.
|
||||
|
||||
|
||||
```js
|
||||
minify = require('minify');
|
||||
```
|
||||
After minification, a file will be saved in the temporary directory.
|
||||
|
||||
minify - function to minificate js, html and css-files.
|
||||
|
||||
- **file** - path to file.
|
||||
- **options**(optional) - object contains options.
|
||||
- **callback**
|
||||
|
||||
Possible options:
|
||||
- **name**
|
||||
- **stream**
|
||||
|
||||
**Examples**:
|
||||
|
||||
## Optimize file
|
||||
```js
|
||||
var minify = require('minify');
|
||||
|
||||
minify('client.js', 'name', function(error, name) {
|
||||
console.log(error || name);
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
minify('client.js', 'stream', function(error, stream) {
|
||||
var streamWrite = fs.createWriteStream('client.min.js');
|
||||
|
||||
if (error)
|
||||
console.error(error.message);
|
||||
else
|
||||
stream.pipe(streamWrite);
|
||||
});
|
||||
```
|
||||
|
||||
if post processing is need:
|
||||
|
||||
```js
|
||||
minify('client.js', function(error, data) {
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
## Optimize data
|
||||
|
||||
Parameters:
|
||||
- Data
|
||||
- Callback
|
||||
|
||||
**Example**:
|
||||
|
||||
```js
|
||||
minify.js('function hello() { if (2 > 3) console.log(\'for real\')}', function(error, data) {
|
||||
console.log(error, data);
|
||||
});
|
||||
|
||||
minify.css('div { color: #000000}', function(error, data) {
|
||||
console.log(error, data);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
## Express middleware
|
||||
|
||||
To use as express middleware [mollify](https://github.com/coderaiser/node-mollify Mollify) could be used.
|
||||
|
||||
License
|
||||
---------------
|
||||
|
||||
MIT
|
22
node_modules/minify/LICENSE
generated
vendored
Normal file
22
node_modules/minify/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2016 Coderaiser <mnemonic.enemy@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
71
node_modules/minify/README.md
generated
vendored
Normal file
71
node_modules/minify/README.md
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
Minify [![License][LicenseIMGURL]][LicenseURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![NPM version][NPMIMGURL]][NPMURL]
|
||||
===============
|
||||
[NPMIMGURL]: https://img.shields.io/npm/v/minify.svg?style=flat
|
||||
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/minify/master.svg?style=flat
|
||||
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/minify.svg?style=flat
|
||||
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
||||
[NPM_INFO_IMG]: https://nodei.co/npm/minify.png?stars
|
||||
[NPMURL]: http://npmjs.org/package/minify
|
||||
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
||||
[BuildStatusURL]: http://travis-ci.org/coderaiser/minify "Build Status"
|
||||
[DependencyStatusURL]: https://david-dm.org/coderaiser/minify "Dependency Status"
|
||||
|
||||
[Minify](http://coderaiser.github.io/minify "Minify") - a minifier of js, css, html and img files.
|
||||
To use `minify` as middleware try [Mollify](https://github.com/coderaiser/node-mollify "Mollify").
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm i minify -g
|
||||
```
|
||||
|
||||
## How to use?
|
||||
|
||||
### CLI
|
||||
|
||||
```js
|
||||
$ cat > hello.js
|
||||
const hello = 'world';
|
||||
|
||||
for (let i = 0; i < hello.length; i++) {
|
||||
console.log(hello[i]);
|
||||
}
|
||||
^D
|
||||
|
||||
$ minify hello.js
|
||||
const hello="world";for(let l=0;l<hello.length;l++)console.log(hello[l]);
|
||||
```
|
||||
|
||||
### Code Example
|
||||
|
||||
`minify` can be used as a `promise`:
|
||||
|
||||
```js
|
||||
const minify = require('minify');
|
||||
|
||||
minify('./client.js')
|
||||
.then(console.log)
|
||||
.catch(console.error);
|
||||
|
||||
```
|
||||
|
||||
Or with `async-await` and [try-to-catch](https://github.com/coderaiser/try-to-catch'):
|
||||
|
||||
```js
|
||||
const minify = require('minify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
|
||||
async () => {
|
||||
const [error, data] = await tryToCatch(minify, './client.js');
|
||||
|
||||
if (error)
|
||||
return console.error(error.message);
|
||||
|
||||
console.log(data);
|
||||
}();
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
100
node_modules/minify/bin/minify.js
generated
vendored
Normal file
100
node_modules/minify/bin/minify.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const Pack = require('../package');
|
||||
const Version = Pack.version;
|
||||
|
||||
const log = function(...args) {
|
||||
console.log(...args);
|
||||
process.stdin.pause();
|
||||
};
|
||||
|
||||
const Argv = process.argv;
|
||||
const files = Argv.slice(2);
|
||||
const [In] = files;
|
||||
|
||||
log.error = function(e) {
|
||||
console.error(e);
|
||||
process.stdin.pause();
|
||||
};
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
if (error.code !== 'EPIPE')
|
||||
log(error);
|
||||
});
|
||||
|
||||
minify();
|
||||
|
||||
function readStd(callback) {
|
||||
const stdin = process.stdin;
|
||||
let chunks = '';
|
||||
const read = () => {
|
||||
const chunk = stdin.read();
|
||||
|
||||
if (chunk)
|
||||
return chunks += chunk;
|
||||
|
||||
stdin.removeListener('readable', read);
|
||||
callback(chunks);
|
||||
};
|
||||
|
||||
stdin.setEncoding('utf8');
|
||||
stdin.addListener('readable', read);
|
||||
}
|
||||
|
||||
function minify() {
|
||||
if (!In || /^(-h|--help)$/.test(In))
|
||||
return help();
|
||||
|
||||
if (/^--(js|css|html)$/.test(In))
|
||||
return readStd(processStream);
|
||||
|
||||
if (/^(-v|--version)$/.test(In))
|
||||
return log('v' + Version);
|
||||
|
||||
uglifyFiles(files);
|
||||
}
|
||||
|
||||
function processStream(chunks) {
|
||||
const minify = require('..');
|
||||
const tryCatch = require('try-catch');
|
||||
|
||||
if (!chunks || !In)
|
||||
return;
|
||||
|
||||
const name = In.replace('--', '');
|
||||
|
||||
const [e, data] = tryCatch(minify[name], chunks);
|
||||
if (e)
|
||||
return log.error(e);
|
||||
|
||||
log(data);
|
||||
}
|
||||
|
||||
function uglifyFiles(files) {
|
||||
const minify = require('..');
|
||||
const minifiers = files.map(minify);
|
||||
|
||||
Promise.all(minifiers)
|
||||
.then(logAll)
|
||||
.catch(log.error);
|
||||
}
|
||||
|
||||
function logAll(array) {
|
||||
for (const item of array)
|
||||
log(item);
|
||||
}
|
||||
|
||||
function help() {
|
||||
const bin = require('../help');
|
||||
const usage = 'Usage: minify [options]';
|
||||
|
||||
console.log(usage);
|
||||
console.log('Options:');
|
||||
|
||||
Object.keys(bin).forEach((name) => {
|
||||
console.log(' %s %s', name, bin[name]);
|
||||
});
|
||||
}
|
||||
|
7
node_modules/minify/help.json
generated
vendored
Normal file
7
node_modules/minify/help.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"-h, --help ": "display this help and exit",
|
||||
"-v, --version ": "display version and exit",
|
||||
"--js ": "minify javascript",
|
||||
"--css ": "minify css",
|
||||
"--html ": "minify html"
|
||||
}
|
27
node_modules/minify/lib/css.js
generated
vendored
Normal file
27
node_modules/minify/lib/css.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/* сжимаем код через clean-css */
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const Clean = require('clean-css');
|
||||
|
||||
/**
|
||||
* minify css data.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
module.exports = (data) => {
|
||||
assert(data);
|
||||
|
||||
const {
|
||||
styles,
|
||||
errors,
|
||||
} = new Clean().minify(data);
|
||||
|
||||
const [error] = errors;
|
||||
|
||||
if (error)
|
||||
throw error;
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
42
node_modules/minify/lib/html.js
generated
vendored
Normal file
42
node_modules/minify/lib/html.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/* сжимаем код через htmlMinify */
|
||||
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const Minifier = require('html-minifier');
|
||||
|
||||
const Options = {
|
||||
removeComments: true,
|
||||
removeCommentsFromCDATA: true,
|
||||
removeCDATASectionsFromCDATA: true,
|
||||
collapseWhitespace: true,
|
||||
collapseBooleanAttributes: true,
|
||||
removeAttributeQuotes: true,
|
||||
removeRedundantAttributes: true,
|
||||
useShortDoctype: true,
|
||||
removeEmptyAttributes: true,
|
||||
/* оставляем, поскольку у нас
|
||||
* в элемент fm генерируеться
|
||||
* таблица файлов
|
||||
*/
|
||||
removeEmptyElements: false,
|
||||
removeOptionalTags: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
|
||||
minifyJS: true,
|
||||
minifyCSS: true
|
||||
};
|
||||
|
||||
/**
|
||||
* minify html data.
|
||||
*
|
||||
* @param data
|
||||
* @param callback
|
||||
*/
|
||||
module.exports = (data) => {
|
||||
assert(data);
|
||||
|
||||
return Minifier.minify(data, Options);
|
||||
};
|
||||
|
33
node_modules/minify/lib/img.js
generated
vendored
Normal file
33
node_modules/minify/lib/img.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const {
|
||||
promisify,
|
||||
} = require('util');
|
||||
|
||||
const fromString = promisify(require('css-b64-images').fromString);
|
||||
|
||||
const ONE_KB = Math.pow(2, 10);
|
||||
|
||||
const maxSize = 100 * ONE_KB;
|
||||
|
||||
/**
|
||||
* minify css data.
|
||||
* if can not minify return data
|
||||
*
|
||||
* @param name
|
||||
* @param data
|
||||
*/
|
||||
module.exports = async (name, data) => {
|
||||
const dir = path.dirname(name);
|
||||
const dirRelative = dir + '/../';
|
||||
|
||||
assert(name);
|
||||
assert(data);
|
||||
|
||||
return fromString(data, dir, dirRelative, {
|
||||
maxSize
|
||||
});
|
||||
};
|
||||
|
24
node_modules/minify/lib/js.js
generated
vendored
Normal file
24
node_modules/minify/lib/js.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const terser = require('terser');
|
||||
const assert = require('assert');
|
||||
|
||||
/**
|
||||
* minify js data.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
module.exports = (data) => {
|
||||
assert(data);
|
||||
|
||||
const {
|
||||
error,
|
||||
code,
|
||||
} = terser.minify(data);
|
||||
|
||||
if (error)
|
||||
throw error;
|
||||
|
||||
return code;
|
||||
};
|
||||
|
84
node_modules/minify/lib/minify.js
generated
vendored
Normal file
84
node_modules/minify/lib/minify.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
const DIR = __dirname + '/';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {
|
||||
promisify,
|
||||
} = require('util');
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const readFile = promisify(fs.readFile);
|
||||
|
||||
const log = require('debug')('minify');
|
||||
|
||||
['js', 'html', 'css', 'img'].forEach((name) => {
|
||||
minify[name] = require(DIR + name);
|
||||
});
|
||||
|
||||
module.exports = minify;
|
||||
|
||||
function check(name) {
|
||||
if (!name)
|
||||
throw Error('name could not be empty!');
|
||||
}
|
||||
|
||||
async function minify(name) {
|
||||
const EXT = ['js', 'html', 'css'];
|
||||
|
||||
check(name);
|
||||
|
||||
const ext = path.extname(name).slice(1);
|
||||
const is = ~EXT.indexOf(ext);
|
||||
|
||||
if (!is)
|
||||
throw Error(`File type "${ext}" not supported.`);
|
||||
|
||||
log('optimizing ' + path.basename(name));
|
||||
return optimize(name);
|
||||
}
|
||||
|
||||
function getName(file) {
|
||||
const notObj = typeof file !== 'object';
|
||||
|
||||
if (notObj)
|
||||
return file;
|
||||
|
||||
return Object.keys(file)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* function minificate js,css and html files
|
||||
*
|
||||
* @param files - js, css or html file path
|
||||
*/
|
||||
async function optimize(file) {
|
||||
check(file);
|
||||
|
||||
const name = getName(file);
|
||||
|
||||
log('reading file ' + path.basename(name));
|
||||
|
||||
const data = await readFile(name, 'utf8');
|
||||
return onDataRead(file, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processing of files
|
||||
* @param fileData {name, data}
|
||||
*/
|
||||
async function onDataRead(filename, data) {
|
||||
log('file ' + path.basename(filename) + ' read');
|
||||
|
||||
const ext = path.extname(filename).replace(/^\./, '');
|
||||
|
||||
const optimizedData = await minify[ext](data);
|
||||
|
||||
let b64Optimize;
|
||||
if (ext === 'css')
|
||||
[, b64Optimize] = await tryToCatch(minify.img, filename, optimizedData);
|
||||
|
||||
return b64Optimize || optimizedData;
|
||||
}
|
||||
|
89
node_modules/minify/package.json
generated
vendored
Normal file
89
node_modules/minify/package.json
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"_from": "minify@^4.1.1",
|
||||
"_id": "minify@4.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-D99KM2lBtJbAAAtKkekL5R1rCFQqhx2dMeFl5etybEdTwGjMYvPsWPDH0CSxTXWSmI2Q7Tx7Gx4rRxik5ahgQA==",
|
||||
"_location": "/minify",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "minify@^4.1.1",
|
||||
"name": "minify",
|
||||
"escapedName": "minify",
|
||||
"rawSpec": "^4.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/minifyfromhtml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/minify/-/minify-4.1.1.tgz",
|
||||
"_shasum": "06d7a6faf5c171ac3075b79e5afdbe606c0c1fe5",
|
||||
"_spec": "minify@^4.1.1",
|
||||
"_where": "F:\\projects\\vanillajs-seed\\node_modules\\minifyfromhtml",
|
||||
"author": {
|
||||
"name": "coderaiser",
|
||||
"email": "mnemonic.enemy@gmail.com",
|
||||
"url": "https://github.com/coderaiser"
|
||||
},
|
||||
"bin": {
|
||||
"minify": "bin/minify.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/coderaiser/minify/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"clean-css": "^4.1.6",
|
||||
"css-b64-images": "~0.2.5",
|
||||
"debug": "^4.1.0",
|
||||
"html-minifier": "^3.0.1",
|
||||
"terser": "^3.16.1",
|
||||
"try-catch": "^2.0.0",
|
||||
"try-to-catch": "^1.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Minifier of js, css, html and img",
|
||||
"devDependencies": {
|
||||
"coveralls": "^3.0.0",
|
||||
"eslint": "^5.7.0",
|
||||
"eslint-plugin-node": "^8.0.0",
|
||||
"nyc": "^13.1.0",
|
||||
"redrun": "^7.0.2",
|
||||
"rimraf": "^2.6.1",
|
||||
"tape": "^4.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"homepage": "http://coderaiser.github.io/minify",
|
||||
"keywords": [
|
||||
"minify",
|
||||
"minimize",
|
||||
"js",
|
||||
"css",
|
||||
"img",
|
||||
"html",
|
||||
"base64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/minify.js",
|
||||
"name": "minify",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/coderaiser/minify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc npm test",
|
||||
"lint": "redrun lint:*",
|
||||
"lint:bin": "eslint --rule no-console:0 bin",
|
||||
"lint:lib": "eslint lib test",
|
||||
"report": "nyc report --reporter=text-lcov | coveralls",
|
||||
"test": "tape test/minify.js"
|
||||
},
|
||||
"version": "4.1.1"
|
||||
}
|
Reference in New Issue
Block a user