Skip to content

Commit

Permalink
Add TypeScript typings for core & webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
zcei committed Jan 7, 2018
1 parent 30af728 commit 203622e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Type definitions for @webpack-blocks/core 1.0.0
// Project: webpack-blocks
// Definitions by: Stephan Schneider <https://github.com/zcei>

import { Configuration as WebpackConfig, Condition, Rule, Plugin } from 'webpack'

export function createConfig(configSetter: WebpackBlock[]): object
export function group(configSetters: WebpackBlock[]): WebpackBlock
export function env(envName: string, configSetters: WebpackBlock[]): WebpackBlock
export function match(test: Condition | Condition[], configSetters: Function[]): Function


export interface WebpackBlock {
(context: Object, util: WebpackBlockUtils): WebpackBlockUpdater
}

export interface WebpackBlockUpdater {
(previousConfig: WebpackConfig): WebpackConfig
}

/*~ You can declare types that are available via importing the module */
export interface WebpackBlockUtils {
merge: (configSnippet: WebpackConfig) => WebpackBlockUpdater
addLoader: (loader: Rule) => WebpackBlockUpdater
addPlugin: (plugin: Plugin) => WebpackBlockUpdater
}
27 changes: 27 additions & 0 deletions packages/webpack/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Type definitions for @webpack-blocks/webpack 1.0.0
// Project: webpack-blocks
// Definitions by: Stephan Schneider <https://github.com/zcei>

import {
createConfig,
group,
env,
match,
WebpackBlock,
WebpackBlockUpdater
} from '@webpack-blocks/core'
import { Configuration, Plugin, Entry, Options, Resolve, Output } from 'webpack'
export { createConfig, group, env, match }

export function addPlugins(plugins: Plugin[]): WebpackBlock
export function customConfig(configSnippet: Configuration): WebpackBlockUpdater
export function defineConstants(constants: { [key: string]: any }): WebpackBlock
export function setEnv(envs: string[] | { [key: string]: any }): WebpackBlock
// TODO: support EntryFunc
export function entryPoint(entry: string | string[] | Entry): WebpackBlock
export function performance(perfBudgetOptions: Options.Performance): WebpackBlock
export function resolve(config: Resolve): WebpackBlock
export function setContext(path: string): WebpackBlock
export function setDevTool(devtool: Options.Devtool): WebpackBlock
export function setOutput(output: string | Output): WebpackBlock
export function sourceMaps(devtool?: Options.Devtool): WebpackBlock

0 comments on commit 203622e

Please sign in to comment.