feat(webpack-cdn-inject): new type definition (#45530)

Type definition for small webpack plugin:
- definition file
- tests

https://github.com/drolsen/webpack-cdn-inject#readme

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-06-21 10:10:12 +02:00 committed by GitHub
parent 4bae021f45
commit dd3765e494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 0 deletions

28
types/webpack-cdn-inject/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for webpack-cdn-inject 1.0
// Project: https://github.com/drolsen/webpack-cdn-inject#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'webpack';
/**
* Plugin to inject CDN assets into HTML documents.
*/
declare namespace WebpackCDNInject {
interface Options {
/**
* Defines urls to be added to document head (tag type is defined by url's file extension).
*/
head?: string[];
/**
* Defines urls to be added to document body (tag type is defined by url's file extension).
*/
body?: string[];
}
}
declare class WebpackCDNInject extends Plugin {
constructor(options?: WebpackCDNInject.Options);
}
export = WebpackCDNInject;

View 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",
"webpack-cdn-inject-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,19 @@
import { Configuration } from 'webpack';
import WebpackCDNInject = require('webpack-cdn-inject');
const config: Configuration = {
plugins: [
new WebpackCDNInject(),
new WebpackCDNInject({}),
new WebpackCDNInject({
body: ['url.js', 'url.css'],
}),
new WebpackCDNInject({
head: ['url.css', 'url.js'],
}),
new WebpackCDNInject({
body: ['url.js', 'url.css'],
head: ['url.css', 'url.js'],
}),
],
};