mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(minify): new definition (#47290)
- definition file - tests https://github.com/coderaiser/minify Thanks!
This commit is contained in:
parent
8d3bdc7cde
commit
b4596f89b7
46
types/minify/index.d.ts
vendored
Normal file
46
types/minify/index.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Type definitions for minify 5.1
|
||||
// Project: http://coderaiser.github.io/minify
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import htmlMinifier = require('html-minifier');
|
||||
import cleanCSS = require('clean-css');
|
||||
import terser = require('terser');
|
||||
|
||||
/**
|
||||
* A minifier of js, css, html and img files.
|
||||
* @async
|
||||
*/
|
||||
declare function minify(name: string, options?: minify.Options): Promise<string>;
|
||||
|
||||
declare namespace minify {
|
||||
/**
|
||||
* Full documentation for options that each file type accepts
|
||||
* can be found on the pages of the libraries used by minify to process the files
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* @see {@link https://github.com/kangax/html-minifier}
|
||||
*/
|
||||
html?: htmlMinifier.Options;
|
||||
/**
|
||||
* @see {@link https://github.com/jakubpawlowicz/clean-css}
|
||||
*/
|
||||
css?: cleanCSS.Options;
|
||||
/**
|
||||
* @see {@link https://github.com/terser/terser}
|
||||
*/
|
||||
js?: terser.MinifyOptions;
|
||||
/**
|
||||
* @see {@link https://github.com/Filirom1/css-base64-images}
|
||||
*/
|
||||
img?: {
|
||||
/**
|
||||
* bigger images are not base64 in the CSS
|
||||
* @default 4096
|
||||
*/
|
||||
maxSize?: number;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export = minify;
|
||||
25
types/minify/minify-tests.ts
Normal file
25
types/minify/minify-tests.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import minify = require('minify');
|
||||
import { Options } from 'minify';
|
||||
|
||||
const options: Options = {
|
||||
html: {
|
||||
removeAttributeQuotes: false,
|
||||
removeOptionalTags: false,
|
||||
},
|
||||
css: {
|
||||
compatibility: '*',
|
||||
},
|
||||
js: {
|
||||
ecma: 5,
|
||||
},
|
||||
img: {
|
||||
maxSize: 4096,
|
||||
},
|
||||
};
|
||||
|
||||
minify('./client.js'); // $ExpectType Promise<string>
|
||||
minify('./client.js', options); // $ExpectType Promise<string>
|
||||
|
||||
(async () => {
|
||||
const data = await minify('./client.js', options); // $ExpectType string
|
||||
})();
|
||||
6
types/minify/package.json
Normal file
6
types/minify/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"terser": "^5.3.0"
|
||||
}
|
||||
}
|
||||
23
types/minify/tsconfig.json
Normal file
23
types/minify/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"minify-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/minify/tslint.json
Normal file
1
types/minify/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user