feat(webpack-shell-plugin): definition types (#45295)

- definition file
- tests

https://github.com/1337programming/webpack-shell-plugin
https://www.npmjs.com/package/webpack-shell-plugin#example

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-06-11 20:38:04 +02:00 committed by GitHub
parent f16a94d91b
commit ab4dade120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 116 additions and 0 deletions

51
types/webpack-shell-plugin/index.d.ts vendored Normal file
View File

@ -0,0 +1,51 @@
// Type definitions for webpack-shell-plugin 0.5
// Project: https://github.com/1337programming/webpack-shell-plugin
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'webpack';
declare class WebpackShellPlugin extends Plugin {
constructor(options?: WebpackShellPlugin.Options);
}
declare namespace WebpackShellPlugin {
interface Options {
/**
* scripts to execute on the initial build
* @default []
*/
onBuildStart?: string[];
/**
* scripts to execute after files are emitted at the end of the compilation
* @default []
*/
onBuildEnd?: string[];
/**
* scripts to execute after webpack process is complete
* @default []
*/
onBuildExit?: string[];
/**
* Switch for development environments.
* This causes scripts to execute once.
* Useful for running HMR on webpack-dev-server or webpack watch mode.
* @default true
*/
dev?: boolean;
/**
* Switches script execution process from spawn to exec.
* If running into problems with spawn, turn this setting on.
* @default false
*/
safe?: boolean;
/**
* Enable for verbose output
* @deprecated
* @default false
*/
verbose?: boolean;
}
}
export = WebpackShellPlugin;

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-shell-plugin-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,41 @@
/// <reference types="webpack-dev-server" />
import WebpackShellPlugin = require('webpack-shell-plugin');
import path = require('path');
import { Configuration, Plugin } from 'webpack';
import { Options } from 'webpack-shell-plugin';
const options: Options = {};
const plugins: Plugin[] = [
new WebpackShellPlugin(),
new WebpackShellPlugin({}),
new WebpackShellPlugin(options),
new WebpackShellPlugin({
onBuildStart: ['echo "Starting"'],
onBuildEnd: ['python script.py && node script.js'],
dev: false,
onBuildExit: ['echo "Exit"', 'echo "Done"'],
safe: true,
}),
];
const _: Configuration = {
entry: {
app: path.resolve(__dirname, 'src/app.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
devServer: {
contentBase: path.resolve(__dirname, 'src'),
},
plugins,
module: {
rules: [
{ test: /\.js$/, loaders: 'babel' },
{ test: /\.scss$/, loader: 'style!css!scss?' },
{ test: /\.html$/, loader: 'html-loader' },
],
},
};