UNPKG

webpack-genius

Version:

**For chinese developers:** you'd better add taobao mirror before everything start. Or you may fail to install. ```bash yarn config set registry http://registry.npm.taobao.org ```

92 lines (91 loc) 4.58 kB
import * as webpack from 'webpack'; import { TerserPluginOptions } from 'terser-webpack-plugin'; import { Configuration, Output, Options, Resolve, Plugin, RuleSetRule, Module } from 'webpack'; import { HotModule } from './plugins/HotModule'; import { PluginHandle } from './plugins/PluginHandle'; import { HashedModuleIds } from './plugins/HashedModuleIds'; import { Html as HtmlPlugin } from './plugins/Html'; import { Html as HtmlRule } from './rules/Html'; import { Clean } from './plugins/Clean'; import { MiniCss } from './plugins/MiniCss'; import WebpackDevServer from 'webpack-dev-server'; import { RuleHandle } from './rules/RuleHandle'; import { Tsx } from './rules/Tsx'; import { Jsx } from './rules/Jsx'; import { Css } from './rules/Css'; import { Scss } from './rules/Scss'; import { Less } from './rules/Less'; import { LessAntd } from './rules/LessAntd'; import { Asset } from './rules/Asset'; import { Gzip } from './plugins/Gzip'; import { Copy } from './plugins/Copy'; import { Define } from './plugins/Define'; import { CssNodeModules } from './rules/CssNodeModules'; import { Json5 } from './rules/Json5'; import { ProgressBar } from './plugins/ProgressBar'; import { Preload } from './plugins/Preload'; import { ReactRefresh } from './plugins/ReactRefresh'; import { ErrorOverlay } from './plugins/ErrorOverlay'; import { AntdDayJs } from './plugins/AntdDayJs'; export declare class WebpackGenius { readonly webpack: typeof webpack; private readonly config; private readonly plugins; private readonly rules; private readonly environment; private readonly port; private uglifyConfig?; constructor(environment: string, port: number); getConfig(): Configuration; hasPackage(name: string): boolean; getPackageField(name: string): any; getPort(): number; getEnvironment(): string; isHot(): boolean; isBuild(): boolean; switchChunkHash(hashNumber?: number): string; switchContentHash(hashNumber?: number): string; getUglifyConfig(): TerserPluginOptions | undefined; setUglifyConfig(config: TerserPluginOptions): this; target(target: Configuration['target']): this; devtool(devtool: Options.Devtool | ((webpack: this) => Options.Devtool)): this; mode(mode: Configuration['mode'] | ((webpack: this) => Configuration['mode'])): this; noParse(pattern: Module['noParse']): this; optimization(fn: (optimization: Options.Optimization, webpack: this) => Options.Optimization | void): this; output(fn: (output: Output, webpack: this) => Output | void): this; miniCss(is: boolean): this; devServer(fn: (server: WebpackDevServer.Configuration, webpack: this) => WebpackDevServer.Configuration | void): this; stats(fn: (stats: Options.Stats, webpack: this) => Options.Stats | void): this; entry(entry: NonNullable<Configuration['entry']>): this; getOriginalEntry(): Readonly<Configuration['entry']>; resolve(fn: (resolve: Resolve, webpack: this) => Resolve | void): this; addPlugin(plugin: Plugin): this; pluginHotModuleReplace(fn?: (plugin: HotModule) => void): this; pluginErrorOverlay(fn?: (plugin: ErrorOverlay) => void): this; pluginReactRefresh(fn?: (plugin: ReactRefresh) => void): this; pluginAntdDayJs(fn?: (plugin: AntdDayJs) => void): this; pluginCopy(fn?: (plugin: Copy) => void): this; pluginGzip(fn?: (plugin: Gzip) => void): this; pluginDefine(fn?: (plugin: Define) => void): this; pluginProgressBar(fn?: (plugin: ProgressBar) => void): this; pluginPreload(fn?: (plugin: Preload) => void): this; pluginHtml(fn?: (plugin: HtmlPlugin) => void): this; pluginHashedModule(fn?: (plugin: HashedModuleIds) => void): this; pluginClean(fn?: (plugin: Clean) => void): this; pluginMiniCss(fn?: (plugin: MiniCss) => void): this; addRule(rule: RuleSetRule): this; ruleTsx(fn?: (rule: Tsx) => void): this; ruleJsx(fn?: (rule: Jsx) => void): this; ruleCssNodeModules(fn?: (rule: CssNodeModules) => void): this; ruleCss(fn?: (rule: Css) => void): this; ruleScss(fn?: (rule: Scss) => void): this; ruleLess(fn?: (rule: Less) => void): this; disableCssModule(): this; ruleAntd(fn?: (rule: LessAntd) => void): this; ruleAsset(fn?: (rule: Asset) => void): this; ruleHtml(fn?: (rule: HtmlRule) => void): this; ruleJson5(fn?: (rule: Json5) => void): this; protected collect(): webpack.Configuration; protected findPlugin<T extends PluginHandle>(name: string, or: () => T): T; protected findRule<T extends RuleHandle>(name: string, or: () => T): T; }