Add babel-webpack-plugin and clean-webpack-plugin

This commit is contained in:
Jed Fox
2017-10-24 18:02:09 -04:00
parent c698079f5a
commit 58300cf58c
8 changed files with 144 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import BabelWebpackPlugin = require('babel-webpack-plugin');
new BabelWebpackPlugin();
new BabelWebpackPlugin({});
new BabelWebpackPlugin({
test: /\.js$/,
presets: ['es2015'],
sourceMaps: false,
compact: false
});

22
types/babel-webpack-plugin/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for clean-webpack-plugin 0.1
// Project: https://github.com/johnagan/clean-webpack-plugin
// Definitions by: Jed Fox <https://github.com/j-f1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'webpack';
import { TransformOptions } from 'babel-core';
export = BabelWebpackPlugin;
declare class BabelWebpackPlugin extends Plugin {
constructor(options?: BabelWebpackPlugin.Options);
}
declare namespace BabelWebpackPlugin {
type Matcher = RegExp | string | Array<RegExp | string>;
interface Options extends TransformOptions {
test?: Matcher;
include?: Matcher;
exclude?: Matcher;
}
}

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",
"babel-webpack-plugin-tests.ts"
]
}

View File

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

View File

@@ -0,0 +1,17 @@
import * as CleanWebpackPlugin from 'clean-webpack-plugin';
const paths = [
'path',
'glob/**/*.js',
];
new CleanWebpackPlugin(paths);
new CleanWebpackPlugin(paths, 'root-directory');
new CleanWebpackPlugin(paths, {});
new CleanWebpackPlugin(paths, {
root: 'root-directory',
verbose: true,
dry: true,
watch: true,
exclude: ['a, b'],
});

47
types/clean-webpack-plugin/index.d.ts vendored Normal file
View File

@@ -0,0 +1,47 @@
// Type definitions for clean-webpack-plugin 0.1
// Project: https://github.com/johnagan/clean-webpack-plugin
// Definitions by: Jed Fox <https://github.com/j-f1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'webpack';
export = CleanWebpackPlugin;
declare class CleanWebpackPlugin extends Plugin {
/**
* @param paths A glob or array of globs to delete
*/
constructor(paths: string | ReadonlyArray<string>, options?: string | CleanWebpackPlugin.Options);
}
declare namespace CleanWebpackPlugin {
interface Options {
/**
* Absolute path to your webpack root folder (paths appended to this)
* Default: root of your package
*/
root?: string;
/**
* Write logs to the console.
*/
verbose?: boolean;
/**
* Set to `true` to emulate deletion without actually removing any files.
*/
dry?: boolean;
/**
* If true, remove files on recompile.
*/
watch?: boolean;
/**
* Instead of removing whole path recursively,
* remove all path's content with exclusion of provided immediate children.
* Good for not removing shared files from build directories.
*/
exclude?: ReadonlyArray<string>;
/**
* Allow the plugin to clean folders outside of the webpack root
*/
allowExternal?: boolean;
}
}

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",
"clean-webpack-plugin-tests.ts"
]
}

View File

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