Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

Adding typescript definitions to package #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import copyWebpackPlugin = require("copy-webpack-plugin");

type CwpParams = ConstructorParameters<typeof copyWebpackPlugin>;
type CopyPattern = Exclude<CwpParams[0][0],string>
type CopyWebpackPluginConfiguration = CwpParams[1];

declare interface CopySpec {
path: string,
dist?: string,
cwpPatternConfig?: CopyPattern,
}

declare interface EntrySpec extends CopySpec {
type?: 'js' | 'css',
attributes?: Record<string,string>
};

declare interface ExternalsDefinition {
module: string,
dist?: string,
entry: string | EntrySpec | Array<string | EntrySpec>,
global?: string | null,
supplements: Array<string | CopySpec>,
append?: boolean,
}

export = class HtmlWebpackExternalsPlugin {
constructor(options: {
externals: ExternalsDefinition[],
hash?: boolean,
outputPath?: string,
publicPath?: string | null,
files?: string | string[] | null,
cwpOptions?: CopyWebpackPluginConfiguration,
enabled?: boolean,
});
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down