/** * Static Assets Plugin for Rspack * * Supports importing static files from shared/static directory: * - JSON files → bundled into HTML, injected as window.__STATIC_JSON__ * - Other files → converted to URL {clientBasePath}/static/path * * Usage: * import config from '@shared/static/config.json'; * import logoUrl from '@shared/static/images/logo.png'; */ import type { IncomingMessage, ServerResponse } from 'http'; import type { Compiler } from '@rspack/core'; export interface StaticAssetsPluginOptions { /** * Client base path prefix for routes * @default '' */ clientBasePath?: string; /** * Root directory for the project * @default process.cwd() */ rootDir?: string; } export declare class StaticAssetsPlugin { private options; private staticDir; private jsonDataCache; private virtualModules; constructor(options?: StaticAssetsPluginOptions); /** * Get the key for a static file path (used for __STATIC_JSON__) */ private getJsonKey; /** * Scan and read all JSON files from shared/static directory */ private scanJsonFiles; /** * Get JSON data (with caching) */ private getJsonData; /** * Generate virtual module content for a static file import */ private generateVirtualModuleContent; /** * Get the script content for __STATIC_JSON__ injection */ private getStaticJsonScriptContent; /** * Create a dev server middleware that serves static files from shared/static. * This aligns with the Vite preset's configureServer middleware. */ createDevMiddleware(): (req: IncomingMessage, res: ServerResponse, next: () => void) => void; apply(compiler: Compiler): void; } export default StaticAssetsPlugin;