UNPKG

2.63 kBTypeScriptView Raw
1import WebpackChainConfig from 'webpack-chain';
2import { Config } from './commands/args';
3import { BabelRC } from './utils/babel-config';
4export declare type SetConfig = (config: Config) => Config | Promise<Config>;
5export declare type ModifyBundlerConfig<C = any> = (config: C, dev: boolean, args: Config) => C;
6export declare type ModifyBabelRC = (babelrc: BabelRC, args: Config) => BabelRC;
7export declare type ModifyFiles = (files: string[], args: Config) => string[];
8export declare type OnCreateWebpackChain = (config: WebpackChainConfig, dev: boolean, args: Config) => void;
9export declare type onPreCreateApp = <A>(app: A) => void;
10export declare type onCreateApp = <A>(app: A) => void;
11export declare type OnServerListening = <S>(server: S) => void;
12export declare type OnPreBuild = (args: Config) => void;
13export declare type OnPostBuild = (args: Config) => void;
14export declare type OnPreRender = () => void;
15export declare type OnPostRender = () => void;
16export interface PluginFactory {
17 setConfig?: SetConfig;
18 modifyBundlerConfig?: ModifyBundlerConfig;
19 modifyBabelRc?: ModifyBabelRC;
20 modifyFiles?: ModifyFiles;
21 onCreateWebpackChain?: OnCreateWebpackChain;
22 onPreCreateApp?: onPreCreateApp;
23 onCreateApp?: onCreateApp;
24 onServerListening?: OnServerListening;
25 onPreBuild?: OnPreBuild;
26 onPostBuild?: OnPostBuild;
27 onPreRender?: OnPreRender;
28 onPostRender?: OnPostRender;
29}
30export declare class Plugin<C = any> implements PluginFactory {
31 static runPluginsMethod(plugins: Plugin[] | undefined): (method: keyof Plugin, ...args: any[]) => void;
32 static propsOfPlugins(plugins: Plugin[]): (prop: keyof Plugin) => any[];
33 static reduceFromPlugins<C>(plugins: Plugin[] | undefined): (method: keyof Plugin, initial: C, ...args: any[]) => C;
34 static reduceFromPluginsAsync<C>(plugins: Plugin[] | undefined): (method: keyof Plugin, initial: C, ...args: any[]) => Promise<C>;
35 readonly setConfig?: SetConfig;
36 readonly modifyBundlerConfig?: ModifyBundlerConfig<C>;
37 readonly modifyBabelRc?: ModifyBabelRC;
38 readonly modifyFiles?: ModifyFiles;
39 readonly onCreateWebpackChain?: OnCreateWebpackChain;
40 readonly onPreCreateApp?: onPreCreateApp;
41 readonly onCreateApp?: onCreateApp;
42 readonly onServerListening?: OnServerListening;
43 readonly onPreBuild?: OnPreBuild;
44 readonly onPostBuild?: OnPostBuild;
45 readonly onPreRender?: OnPreRender;
46 readonly onPostRender?: OnPostRender;
47 constructor(p: PluginFactory);
48}
49export declare function createPlugin<C = any>(factory: PluginFactory): Plugin<C>;