diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts new file mode 100644 index 00000000..4f00a149 --- /dev/null +++ b/packages/core/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for @webpack-blocks/core 1.0.0 +// Project: webpack-blocks +// Definitions by: Stephan Schneider + +import { Configuration as WebpackConfig, Condition, Rule, Plugin } from 'webpack' + +export function createConfig(configSetter: Block[]): object +export function group(configSetters: Block[]): Block +export function env(envName: string, configSetters: Block[]): Block +export function match(test: Condition | Condition[], configSetters: Block[]): Block +export function when(condition: boolean, configSetter: Block[]): Block + +export interface BlockCreator { + (...args: any[]): Block +} + +export interface Block { + (context: Object, util: WebpackBlockUtils): WebpackConfigUpdater +} + +export interface WebpackConfigUpdater { + (previousConfig: WebpackConfig): WebpackConfig +} + +/*~ You can declare types that are available via importing the module */ +export interface WebpackBlockUtils { + merge: (configSnippet: WebpackConfig) => WebpackConfigUpdater + addLoader: (loader: Rule) => WebpackConfigUpdater + addPlugin: (plugin: Plugin) => WebpackConfigUpdater +} diff --git a/packages/tslint/index.d.ts b/packages/tslint/index.d.ts new file mode 100644 index 00000000..85cd5118 --- /dev/null +++ b/packages/tslint/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for @webpack-blocks/tslint 1.0.0 +// Project: webpack-blocks +// Definitions by: Stephan Schneider + +import { Block } from '@webpack-blocks/core' +import { Configuration, ILinterOptions } from 'tslint' + + +type TSLintLoaderOptions = ILinterOptions & { + configuration: Configuration.IConfigurationFile + tsConfigFile: string + typeCheck: boolean + emitErrors: boolean + failOnHint: boolean + fileOutput: { + dir: string + ext: string + clean: boolean + header: string + footer: string + } +} + +declare function tslint(options: TSLintLoaderOptions): Block +export = tslint diff --git a/packages/typescript/index.d.ts b/packages/typescript/index.d.ts new file mode 100644 index 00000000..3cadd27d --- /dev/null +++ b/packages/typescript/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @webpack-blocks/typescript 1.0.0 +// Project: webpack-blocks +// Definitions by: Stephan Schneider + +import { Block } from '@webpack-blocks/core' + +import { LoaderConfig } from 'awesome-typescript-loader/dist/interfaces' + +declare function typescript (options: LoaderConfig): Block +export = typescript diff --git a/packages/webpack/index.d.ts b/packages/webpack/index.d.ts new file mode 100644 index 00000000..7d7f5754 --- /dev/null +++ b/packages/webpack/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for @webpack-blocks/webpack 1.0.0 +// Project: webpack-blocks +// Definitions by: Stephan Schneider + +import { + createConfig, + group, + env, + match, + Block, + WebpackConfigUpdater +} from '@webpack-blocks/core' +import { Configuration, Plugin, Entry, Options, Resolve, Output } from 'webpack' +export { createConfig, group, env, match } + +export function addPlugins(plugins: Plugin[]): Block +export function customConfig(configSnippet: Configuration): Block +export function defineConstants(constants: { [key: string]: any }): Block +export function setEnv(envs: string[] | { [key: string]: any }): Block +// TODO: support EntryFunc +export function entryPoint(entry: string | string[] | Entry): Block +export function performance(perfBudgetOptions: Options.Performance): Block +export function resolve(config: Resolve): Block +export function setContext(path: string): Block +export function setDevTool(devtool: Options.Devtool): Block +export function setOutput(output: string | Output): Block +export function sourceMaps(devtool?: Options.Devtool): Block