mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 09:27:19 +08:00
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { ServerPlugin } from './server';
|
|
import { Plugin as RollupPlugin } from 'rollup';
|
|
import { SourceMap } from './server/serverPluginSourceMap';
|
|
import { InternalResolver } from './resolver';
|
|
declare type ParsedQuery = Record<string, string | string[] | undefined>;
|
|
interface TransformTestContext {
|
|
/**
|
|
* Full specifier of the transformed module, including query parameters
|
|
*/
|
|
id: string;
|
|
/**
|
|
* Path without query (use this to check for file extensions)
|
|
*/
|
|
path: string;
|
|
/**
|
|
* Parsed query object
|
|
*/
|
|
query: ParsedQuery;
|
|
/**
|
|
* Indicates whether this is a request made by js import(), or natively by
|
|
* the browser (e.g. `<img src="...">`).
|
|
*/
|
|
isImport: boolean;
|
|
isBuild: boolean;
|
|
/**
|
|
* Indicates that the file for this request was not modified since last call.
|
|
*/
|
|
notModified?: true;
|
|
}
|
|
export interface TransformContext extends TransformTestContext {
|
|
code: string;
|
|
}
|
|
export interface TransformResult {
|
|
code: string;
|
|
map?: SourceMap;
|
|
}
|
|
export declare type TransformFn = (ctx: TransformContext) => string | TransformResult | Promise<string | TransformResult>;
|
|
export interface Transform {
|
|
test: (ctx: TransformTestContext) => boolean;
|
|
transform: TransformFn;
|
|
}
|
|
export interface IndexHtmlTransformContext {
|
|
code: string;
|
|
isBuild: boolean;
|
|
}
|
|
export declare type IndexHtmlTransformFn = (ctx: IndexHtmlTransformContext) => string | Promise<string>;
|
|
export declare type IndexHtmlTransform = IndexHtmlTransformFn | {
|
|
/**
|
|
* Timing for applying the transform.
|
|
* @default: 'post'
|
|
*/
|
|
apply?: 'pre' | 'post';
|
|
transform: IndexHtmlTransformFn;
|
|
};
|
|
export declare type CustomBlockTransform = TransformFn;
|
|
export declare function createServerTransformPlugin(transforms: Transform[], customBlockTransforms: Record<string, CustomBlockTransform>, resolver: InternalResolver): ServerPlugin;
|
|
export declare function createBuildJsTransformPlugin(transforms: Transform[], customBlockTransforms: Record<string, CustomBlockTransform>): RollupPlugin;
|
|
export {};
|