Add type definition for webpack-subresource-integrity plugin. (#30157)

This commit is contained in:
Jeow Li Huan
2018-10-31 14:11:00 +08:00
committed by John Reilly
parent d105be18dc
commit 3db545b2e2
4 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
// Type definitions for webpack-subresource-integrity 1.2
// Project: https://github.com/waysact/webpack-subresource-integrity
// Definitions by: Jeow Li Huan <https://github.com/huan086>
// Definitions: https://github.com/huan086/webpack-subresource-integrity-typings
// TypeScript Version: 2.3
import { Plugin } from 'webpack';
declare namespace WebpackSubresourceIntegrityPlugin {
interface Options {
/**
* Default value: true
* When this value is falsy, the plugin doesn't run and no integrity values are calculated. It is recommended to disable the plugin in development mode.
*/
enabled?: boolean;
/**
* An array of strings, each specifying the name of a hash function to be used for calculating integrity hash values. For example, ['sha256', 'sha512'].
*/
hashFuncNames: string[];
}
}
declare class WebpackSubresourceIntegrityPlugin extends Plugin {
constructor(options?: WebpackSubresourceIntegrityPlugin.Options);
}
export = WebpackSubresourceIntegrityPlugin;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpack-subresource-integrity-tests.ts"
]
}

View File

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

View File

@@ -0,0 +1,15 @@
import * as webpack from 'webpack';
import SriPlugin = require('webpack-subresource-integrity');
const config: webpack.Configuration = {
plugins: [
new SriPlugin(),
new SriPlugin({
hashFuncNames: ['sha256', 'sha384']
}),
new SriPlugin({
enabled: false,
hashFuncNames: ['sha256']
})
]
};