diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..e4c3131 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,37 @@ +import copyWebpackPlugin = require("copy-webpack-plugin"); + +type CwpParams = ConstructorParameters; +type CopyPattern = Exclude +type CopyWebpackPluginConfiguration = CwpParams[1]; + +declare interface CopySpec { + path: string, + dist?: string, + cwpPatternConfig?: CopyPattern, +} + +declare interface EntrySpec extends CopySpec { + type?: 'js' | 'css', + attributes?: Record +}; + +declare interface ExternalsDefinition { + module: string, + dist?: string, + entry: string | EntrySpec | Array, + global?: string | null, + supplements: Array, + append?: boolean, +} + +export = class HtmlWebpackExternalsPlugin { + constructor(options: { + externals: ExternalsDefinition[], + hash?: boolean, + outputPath?: string, + publicPath?: string | null, + files?: string | string[] | null, + cwpOptions?: CopyWebpackPluginConfiguration, + enabled?: boolean, + }); +} \ No newline at end of file diff --git a/package.json b/package.json index 030838f..07d5dc2 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "externals" ], "main": "lib/index.js", + "types": "index.d.ts", "scripts": { "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files", "postpublish": "create-github-release $TAG", @@ -63,6 +64,7 @@ "html-webpack-plugin": "^2.0.0" }, "dependencies": { + "@types/copy-webpack-plugin": "^4.4.4", "ajv": "^6.1.1", "copy-webpack-plugin": "^4.4.1", "html-webpack-include-assets-plugin": "^1.0.2"