plugin-light
Version:
Webpack 相关插件、Loader、基础配置及 CLI 命令
416 lines (365 loc) • 10.7 kB
TypeScript
/**
* 识别动态组件,自动添加对应componentPlaceholder
*/
declare class AddPlaceHolderPlugin {
apply(compiler: any): void;
}
declare class DepAnalysisPlugin {
depsMap: Record<string, Set<string>>;
reverseDepsMap: Record<string, Set<string>>;
pluginName: String;
constructor();
apply(compiler: any): void;
}
declare class CheckLongConstantPlugin {
pluginName: String;
constructor();
apply(compiler: any): void;
}
type IDir = {
from: string;
to: string;
type?: 'mv' | 'cp';
};
type ICopyDirOptions = {
dirs?: Array<IDir>;
};
declare class CopyDirPlugin {
options: ICopyDirOptions;
constructor(options: ICopyDirOptions);
apply(compiler: any): void;
move(): void;
}
type IHash = string | RegExp | Array<string>;
interface ICustomPreloadOptions {
list?: Array<{
condition: {
hash?: IHash;
path?: IHash;
};
pages?: string | Array<string | Array<string>>;
}>;
}
interface IUniRoutes {
path: string;
name: string;
}
declare class CustomPreloadPlugin {
pluginName: string;
moduleList: never[];
mainChunkFileName: string;
pageChunkList: Array<{
name: string;
chunks: Array<string>;
}>;
uniRoutes: Array<IUniRoutes>;
customPreloadOptions: ICustomPreloadOptions;
constructor(options: ICustomPreloadOptions);
apply(compiler: any): void;
getAllPreloadScripts(): string;
updateHtml(compilation: any, insertCode: string): void;
}
type IDispatchScriptOptions = {
whiteList?: Array<string>;
addCommonVendorRequire?: boolean;
};
type IChunks = Array<{
name: string;
}>;
type IModule = {
resource: string;
type: string;
getChunks: () => any;
};
declare class DispatchScriptPlugin {
options: IDispatchScriptOptions;
moveFiles: Map<any, any>;
pluginName: string;
reverseDepsMap: Record<string, Set<string>>;
handledModules: Array<{
module: string;
subPackages: Array<string>;
}>;
pages: Array<string>;
mainPath: string;
constructor(options: IDispatchScriptOptions);
apply(compiler: any): void;
collectShouldDispatchJS(compilation: any): void;
doDispatchJS({ modules, chunks, compilation, }: {
modules: Array<IModule>;
chunks: IChunks;
compilation: any;
}): void;
collectDeps(result: {
resourceResolveData: Record<string, any>;
}): void;
}
declare const HTML_MAP: {
readonly MP_WX: ".wxml";
readonly MP_QQ: ".qml";
readonly MP_ALIPAY: ".axml";
readonly MP_JD: ".jxml";
};
declare const CSS_MAP: {
readonly MP_WX: ".wxss";
readonly MP_QQ: ".qss";
readonly MP_ALIPAY: ".acss";
readonly MP_JD: ".jxss";
};
type IDispatchVueOptions = {
useFixNpm?: boolean;
insertRequireVendor?: boolean;
needLog?: boolean;
needGlobalComponents?: boolean;
moveComponents?: {
minUseTimes: number;
disableList: Array<string>;
};
};
type IMovingComponents = Array<{
sourceRef: string;
targetRef: string;
subPackage: string;
}>;
type IReplaceRefList = Array<Array<string>>;
declare class DispatchVuePlugin {
options: IDispatchVueOptions;
useFixNpm: boolean;
insertRequireVendor: boolean;
startTime: number;
postFix: {
html: typeof HTML_MAP[keyof typeof HTML_MAP];
css: typeof CSS_MAP[keyof typeof CSS_MAP];
};
constructor(options: IDispatchVueOptions);
apply(compiler: any): void;
copyComponents(assets: Record<string, any>, movingComponents: IMovingComponents): void;
deleteComponents(assets: Record<string, any>, movingComponents: IMovingComponents): void;
deleteFile(assets: Record<string, any>, name: string, postfix: string): void;
addCompChunk(assets: Record<string, any>, origin: string, target: string, postfix: string, insertCode?: string): void;
modifyRef(assets: Record<string, any>, parsedReplaceRefList: IReplaceRefList): void;
}
declare class FixMiniCssPlugin {
apply(compiler: any): void;
}
declare class FixNpmPackagePlugin {
options: object;
constructor(options: object);
apply(compiler: any): void;
}
type IGenVersionOptions = {
buildName?: string;
commitName?: string;
delay?: number;
};
declare class GenVersionWebPlugin {
options: IGenVersionOptions;
constructor(options?: IGenVersionOptions);
apply(compiler: any): void;
}
declare class GenVersionMpPlugin {
options: IGenVersionOptions;
constructor(options: IGenVersionOptions);
apply(compiler: any): void;
}
declare class GlobalThisPolyfillPlugin {
options: any;
constructor(options?: {});
apply(compiler: any): void;
}
interface IInsertGlobalCompOptions {
list?: Array<string>;
namespace?: string;
}
declare class InsertGlobalCompPlugin {
options: IInsertGlobalCompOptions;
constructor(options: IInsertGlobalCompOptions);
apply(compiler: any): void;
}
interface InsertScriptOptions {
scripts?: Array<string>;
}
declare class InsertScriptPlugin {
options: InsertScriptOptions;
constructor(options?: InsertScriptOptions);
apply(compiler: any): void;
}
declare class ManifestExposePlugin {
constructor(options?: {});
options: {
jsSrc: string;
cssSrc: string;
};
getCssChunkObject(mainChunk: any): {};
apply(compiler: any): void;
}
declare const HtmlModifyPlugin: (options: any) => void;
declare class RemToRpxPlugin {
whiteList: Array<string>;
factor: number;
unit: string;
fileSuffix: Array<string>;
constructor(options?: {
whiteList?: Array<string>;
factor?: number;
unit?: string;
fileSuffix?: Array<string>;
});
apply(complier: any): void;
}
type IReplaceAppIdOptions = {
appId: string;
};
declare class ReplaceAppIdPlugin {
appId: string;
constructor(options: IReplaceAppIdOptions);
apply(complier: any): void;
doReplace(compilation: any, cb: Function): void;
}
type IReplaceList = Array<{
from: string | RegExp;
to: string;
files?: Array<string | RegExp>;
}>;
type IReplaceContentOptions = {
replaceReg: RegExp;
fileNameReg: RegExp;
replaceList: IReplaceList;
};
declare class ReplaceContentPlugin {
replaceReg: RegExp;
fileNameReg: RegExp;
replaceList: IReplaceList;
replaceMap: Record<any, any>;
constructor(options: IReplaceContentOptions);
apply(complier: any): void;
doReplace(compilation: any, cb: Function): void;
}
interface IReplaceUniH5PluginOption {
version: String;
}
declare class ReplaceUniH5Plugin {
pluginName: String;
uniH5Version: String;
constructor(options: IReplaceUniH5PluginOption);
apply(compiler: any): void;
}
declare class SaveLoaderLogPlugin {
options: object;
constructor(options: object);
apply(compiler: any): void;
}
declare function recordLoaderLog(file: string, content: any): void;
type ITransferLocalFileOptions = {
isModifyRef?: boolean;
adapterDirs?: Array<string>;
};
declare class TransferLocalFilePlugin {
options?: ITransferLocalFileOptions;
constructor(options: ITransferLocalFileOptions);
apply(compiler: any): void;
moveComp(assets: Record<string, any>): void;
modifyRef(assets: Record<string, any>): void;
}
type IAddCodeAtEndItem = {
id: string;
code: string;
exact?: boolean;
number?: number;
};
type IAddCodeAtEndOptions = {
list?: Array<IAddCodeAtEndItem>;
};
declare function addCodeAtEndVitePlugin(options?: IAddCodeAtEndOptions): {
name: string;
transform(source: string, id: string): string | {
code: string;
map: null;
};
};
type IAliasForLibraryOptions = {
list?: Array<string>;
target?: string;
root?: string;
};
declare function aliasForLibrary(options?: IAliasForLibraryOptions): {
name: string;
buildStart(): void;
};
type ICrossGameStyleOptions = {
styleName?: string;
};
/**
* Vite 插件 - 将多游戏样式文件占位符 `@TIP_STYLE_NAME` 转为 对应的文件路径
* @param options.styleName - 样式名称
*/
declare function crossGameStyleVitePlugin(options?: ICrossGameStyleOptions): {
name: string;
transform(source: string, id: string): {
code: string;
map: null;
};
};
type ICrossPlatformOptions = {
platform?: string;
};
/**
* Vite 插件 - 替换跨平台占位符`@TIP_PLATFORM_NAME`
* @param options.platform - VUE_APP_PLATFORM 对应的名称
*/
declare function crossPlatformVitePlugin(options?: ICrossPlatformOptions): {
name: string;
enforce: string;
transform(source: string): {
code: string;
map: null;
};
};
declare function genVersionMpVitePlugin(): {
name: string;
renderChunk(code: string, chunk: Record<string, any>): string;
};
declare function genVersionWebVitePlugin(options: IGenVersionOptions): {
name: string;
transform(code: string, id: string): string;
transformIndexHtml(code: string): string;
};
type IIfdefOptions = {
context?: Record<string, boolean>;
log?: boolean;
type: Array<string>;
};
declare function ifdefVitePlugin(options?: IIfdefOptions): {
name: string;
enforce: string;
transform(source: string, id: string): {
code: string;
map: null;
};
};
declare function remToRpxVitePlugin(): {
name: string;
transform(source: string, id: string): {
code: string;
map: null;
} | undefined;
};
/**
* Vite 插件 - 将 `aComp(resolve){ require(['xx.vue'], resolve) }` 转为 `aComp: () => import('xx.vue')`
*/
declare function replaceRequireDynamicVitePlugin(): {
name: string;
transform(source: string, id: string): {
code: string;
map: null;
};
};
declare function transformVLazyVitePlugin(): {
name: string;
enforce: string;
transform(source: string): {
code: string;
map: null;
};
};
export { AddPlaceHolderPlugin, CheckLongConstantPlugin, CopyDirPlugin, CustomPreloadPlugin, DepAnalysisPlugin, DispatchScriptPlugin, DispatchVuePlugin, FixMiniCssPlugin, FixNpmPackagePlugin, GenVersionMpPlugin, GenVersionWebPlugin, GlobalThisPolyfillPlugin, HtmlModifyPlugin, InsertGlobalCompPlugin, InsertScriptPlugin, ManifestExposePlugin, RemToRpxPlugin, ReplaceAppIdPlugin, ReplaceContentPlugin, ReplaceUniH5Plugin, SaveLoaderLogPlugin, TransferLocalFilePlugin, addCodeAtEndVitePlugin, aliasForLibrary, crossGameStyleVitePlugin, crossPlatformVitePlugin, genVersionMpVitePlugin, genVersionWebVitePlugin, ifdefVitePlugin, recordLoaderLog, remToRpxVitePlugin, replaceRequireDynamicVitePlugin, transformVLazyVitePlugin };