mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 19:43:20 +08:00
New typings for zip-webpack-plugin (#27032)
* Typings for zip-webpack-plugin * Switch to ReadonlyArray for include and exclude options * Fix linting errors * Fix TypeScript version
This commit is contained in:
committed by
Mohamed Hegazy
parent
9e79023693
commit
f3c6f4aec3
99
types/zip-webpack-plugin/index.d.ts
vendored
Normal file
99
types/zip-webpack-plugin/index.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// Type definitions for zip-webpack-plugin 3.0
|
||||
// Project: https://github.com/erikdesjardins/zip-webpack-plugin
|
||||
// Definitions by: Blaise Kal <https://github.com/blaise-io>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as webpack from 'webpack';
|
||||
|
||||
export = ZipPlugin;
|
||||
|
||||
/**
|
||||
* Webpack plugin to zip emitted files. Compresses all assets into a zip file.
|
||||
* See https://www.npmjs.com/package/zip-webpack-plugin#usage
|
||||
*/
|
||||
declare class ZipPlugin extends webpack.Plugin {
|
||||
/**
|
||||
* @param options Options for ZipPlugin.
|
||||
*/
|
||||
constructor(options?: ZipPlugin.Options);
|
||||
}
|
||||
|
||||
declare namespace ZipPlugin {
|
||||
interface Options {
|
||||
/**
|
||||
* Output path. Can be relative (to the webpack output path) or absolute.
|
||||
* Defaults to the Webpack output path.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* Output file name.
|
||||
* Defaults to the Webpack output filename or basename of the path.
|
||||
*/
|
||||
filename?: string;
|
||||
/**
|
||||
* The file extension to use instead of "zip".
|
||||
* Defaults to "zip".
|
||||
*/
|
||||
extension?: string;
|
||||
/**
|
||||
* The path prefix for files included in the zip file.
|
||||
* Default to no prefix.
|
||||
*/
|
||||
pathPrefix?: string;
|
||||
/**
|
||||
* Function to map asset paths to new paths.
|
||||
*/
|
||||
pathMapper?: (assetPath: string) => string;
|
||||
/**
|
||||
* Include file paths or patterns.
|
||||
* Defaults to including all files in the webpack output path.
|
||||
*/
|
||||
include?: string | RegExp | ReadonlyArray<string|RegExp>;
|
||||
/**
|
||||
* Exclude file paths or patterns. Takes precedence over include. Defaults to no excluding.
|
||||
*/
|
||||
exclude?: string | RegExp | ReadonlyArray<string|RegExp>;
|
||||
/**
|
||||
* File options passed to yazl `addFile`.
|
||||
* See https://github.com/thejoshwolfe/yazl#addfilerealpath-metadatapath-options
|
||||
*/
|
||||
fileOptions?: fileOptions;
|
||||
/**
|
||||
* File options passed to yazl `end`.
|
||||
* See https://github.com/thejoshwolfe/yazl#endoptions-finalsizecallback
|
||||
*/
|
||||
zipOptions?: zipOptions;
|
||||
}
|
||||
|
||||
interface fileOptions {
|
||||
/**
|
||||
* Overwrite the last modified time.
|
||||
* Defaults to the current date and time.
|
||||
*/
|
||||
mtime?: Date;
|
||||
/**
|
||||
* UNIX permission bits and file type.
|
||||
*/
|
||||
mode?: number;
|
||||
/**
|
||||
* Whether to compress the out[ut zip file.
|
||||
* When true, the file data will be deflated (compression method 8).
|
||||
* When false, the file data will be stored (compression method 0).
|
||||
*/
|
||||
compress?: boolean;
|
||||
/**
|
||||
* Force ZIP64 format. ZIP64 format is enabled by default where necessary.
|
||||
* See https://github.com/thejoshwolfe/yazl#regarding-zip64-support
|
||||
*/
|
||||
forceZip64Format?: boolean;
|
||||
}
|
||||
|
||||
interface zipOptions {
|
||||
/**
|
||||
* Force ZIP64 format. ZIP64 format is enabled by default where necessary.
|
||||
* See https://github.com/thejoshwolfe/yazl#regarding-zip64-support
|
||||
*/
|
||||
forceZip64Format?: boolean;
|
||||
}
|
||||
}
|
||||
23
types/zip-webpack-plugin/tsconfig.json
Normal file
23
types/zip-webpack-plugin/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"zip-webpack-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/zip-webpack-plugin/tslint.json
Normal file
1
types/zip-webpack-plugin/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
28
types/zip-webpack-plugin/zip-webpack-plugin-tests.ts
Normal file
28
types/zip-webpack-plugin/zip-webpack-plugin-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as ZipPlugin from "zip-webpack-plugin";
|
||||
|
||||
new ZipPlugin();
|
||||
|
||||
const options: ZipPlugin.Options = {
|
||||
include: "include.string",
|
||||
exclude: "exclude.string",
|
||||
};
|
||||
new ZipPlugin(options);
|
||||
|
||||
new ZipPlugin({
|
||||
path: "path",
|
||||
filename: "filename",
|
||||
extension: "ext",
|
||||
pathPrefix: "prefix",
|
||||
pathMapper: (assetPath) => `pathMapper/${assetPath}`,
|
||||
include: ["include.string", /include\.regexp/],
|
||||
exclude: ["exclude.string", /exclude\.regexp/],
|
||||
fileOptions: {
|
||||
mtime: new Date(),
|
||||
mode: parseInt("0100664", 8),
|
||||
compress: false,
|
||||
forceZip64Format: true,
|
||||
},
|
||||
zipOptions: {
|
||||
forceZip64Format: true,
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user