import type { Config as SvgoConfig } from 'svgo'; import type { JpegOptions, PngOptions, GifOptions, WebpOptions, AvifOptions } from 'sharp'; import type { ReactRefreshPlugin } from '@pmmmwh/react-refresh-webpack-plugin'; import type { DeduplicateStrategy } from '@tinkoff/webpack-dedupe-plugin'; import type { PluginOptions } from 'image-minimizer-webpack-plugin'; import type { Configuration as WebpackConfiguration } from 'webpack'; import type { TramvaiPlugin } from '../core/plugin'; export interface SharpEncodeOptions { encodeOptions?: { jpeg?: JpegOptions; png?: PngOptions; gif?: GifOptions; webp?: WebpOptions; avif?: AvifOptions; }; } /** * @see https://github.com/waysact/webpack-subresource-integrity/tree/main/webpack-subresource-integrity#options */ export interface IntegrityOptions { enabled: boolean | 'auto'; hashFuncNames: ('sha256' | 'sha384' | 'sha512')[]; hashLoading: 'eager' | 'lazy'; } export type PostcssOptions = { /** * @title Path to postcss config file. By default, `postcss.config.js` file is used */ config?: string; /** * @title CSS identifiers build algorithm */ cssLocalIdentName?: string | { development?: string; production?: string; }; /** * @title Enable CSS modules for all files matching /RegExp/i.test(filename) regexp. */ cssModulePattern?: string; /** * @title Path to postcss config file for assets */ assetsConfig?: string; }; /** * @title File-System Routing feature */ export type FileSystemPagesOptions = { /** * @title Read pages from file system * @default false */ enabled?: boolean; /** * @title Folder with pages from which static routers are generated * @default "routes" */ routesDir?: string | false; /** * @title Folder with components which can be manually added to static routers * @default "pages" */ pagesDir?: string | false; /** * @title Test Regexp to add only files with specific name to list of FS Components */ componentsPattern?: string; /** * @title Path to RootErrorBoundary component (relative to "root" directory) * @default "error.tsx" */ rootErrorBoundaryPath?: string; }; export type HotRefreshOptions = { /** * @title Enable react hot-refresh * @default true */ enabled?: boolean; /** * @title Configure react hot-refresh https://github.com/pmmmwh/react-refresh-webpack-plugin#options * @default {} */ options?: ConstructorParameters[0]; }; export type DevtoolOption = false | 'eval' | 'eval-cheap-source-map' | 'eval-cheap-module-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'inline-source-map' | 'eval-nosources-cheap-source-map' | 'eval-nosources-cheap-module-source-map' | 'eval-nosources-source-map' | 'inline-nosources-cheap-source-map' | 'inline-nosources-cheap-module-source-map' | 'inline-nosources-source-map' | 'nosources-cheap-source-map' | 'nosources-cheap-module-source-map'; export type ReactCompilerOptions = { sources?: Array; compilationMode?: 'infer' | 'annotation' | 'all'; /** * @title Determines the point at which compiler should throw an error */ panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE'; }; type BaseExperiments = { /** * @title Enable Lightningcss for css transpiling as Postcss alternative * @default false */ lightningcss?: boolean; /** * https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts * * @title Enable React Compiler. You can pass some options, or use it with meaningful defaults. * @default false */ reactCompiler?: boolean | ReactCompilerOptions; /** * * https://webpack.js.org/configuration/experiments * * @title Webpack experiments */ webpack?: WebpackConfiguration['experiments']; }; export interface ApplicationExperiments extends BaseExperiments { /** * @title Enable View Transitions API for SPA navigations * @default false */ viewTransitions?: boolean; /** * @title Enable React Transitions for SPA navigations * @default false */ reactTransitions?: boolean; } export interface ChildAppExperiments extends BaseExperiments { } export type TranspilationOptions = { /** * @title customize transpiling of node_modules in prod/dev environments */ include?: { development?: 'all' | 'only-modern' | 'none' | string[]; production?: 'all' | 'only-modern'; }; }; /** * @title Enable DedupePlugin * @default {} */ export type DedupeOptions = { /** * @title Strategy for DedupePlugin * @default true */ enabled: boolean; /** * @title Does DedupePlugin should be enabled in development mode * Why it might be useful see [issue](https://github.com/Tinkoff/tramvai/issues/11) * @default false */ enabledDev: boolean; /** * @title Strategy for DedupePlugin * @default "equality" */ strategy: DeduplicateStrategy; /** * @title Sets ignore to DedupePlugin */ ignore?: string[]; }; /** * @description Serializable parameters from CLI arguments or JS API parameters */ export type InputParameters = { name: string; mode?: 'development' | 'production'; port?: number; host?: string; httpsKey?: string; httpsCert?: string; benchmark?: boolean; runtimeEnv?: Record; sourceMap?: boolean; analyze?: false | 'bundle' | 'whybundled' | 'statoscope' | 'rsdoctor' | 'stats'; staticPort?: number; staticHost?: string; https?: boolean; rootDir?: string; /** * @description Resolve symbolic links to real paths * @default true */ resolveSymlinks?: boolean; /** * @description Build all, or only client or server builds (usually used for performance reasons) * @default "all" */ buildType?: 'client' | 'server' | 'all'; /** * @description Stop watching for changes for server and client builds * @default false */ noRebuild?: boolean; /** * @description Stop watching for changes for server build * @default false */ noServerRebuild?: boolean; /** * @description Stop watching for changes for client build * @default false */ noClientRebuild?: boolean; /** * @description Debug server.js process * @default false */ debug?: string | false; /** * @description Debug build process * @default false */ debugBuild?: string | false; /** * @description Verbose build logging * @default false */ verboseLogging?: boolean; /** * @description Show progressbar of build process * @default false */ showProgress?: boolean; /** * @description Show banner with tips for build process * @default false */ showBanner?: boolean; /** * Enables cache for build * @default true */ fileCache?: boolean; /** * Enables cache profiling * @default false */ cacheProfile?: boolean; /** * Disable server runner start waiting, used for test purposes * @default false */ disableServerRunnerWaiting?: boolean; /** * Disable websocket server and additional entry, used for test purposes * @default false */ disableWebSocketServer?: boolean; /** * Enable experimental server hot reload * @default false */ serverHot?: boolean; }; export type Project = ApplicationProject | ChildAppProject; export interface BaseProject { /** * [svgo](https://github.com/svg/svgo) configuration, used for SVG and [SVGR](https://react-svgr.com/) optimization */ svgo?: SvgoConfig; /** * Enables data-qa-tag plugin for transpiler * @default false */ generateDataQaTag?: boolean; /** * @title Enable babel plugin `fill-declare-action-name` (not supported with swc transpiler) * @default false */ enableFillDeclareActionNamePlugin?: boolean; transpilation?: TranspilationOptions; /** * React hot-refresh options */ hotRefresh?: HotRefreshOptions; /** * Live reload after build in browser */ liveReload?: boolean; /** * @title Configure webpack dev server writeToDisk option * @default false */ writeToDisk?: boolean; /** * Image optimization options */ imageOptimization?: { /** * Enable image-minimizer-webpack-plugin */ enabled?: boolean; /** * Options to image-minimizer-webpack-plugin */ options?: PluginOptions; }; /** * @title Enable source maps for client and server builds * @default { development: false, production: true } */ sourceMap?: boolean | { development: boolean | { client: boolean; server: boolean; }; production: boolean | { client: boolean; server: boolean; }; }; /** * @title backwards compatibility for `*.less` files processing * @deprecated prefer CSS Modules and PostCSS usage, this option will be removed in future releases * @default false */ deprecatedLessSupport?: boolean; /** * @title Specify dependencies that will be shared between application and child-apps * @description Properly defining that dependencies may greatly reduce filesize of loaded js on the client * @default {} */ shared?: { /** * @title Should default dependencies list be added to shared list * @description It includes the list of commonly used dependencies in the child-apps * By default, it is enabled in application in case of tramvai/module-child-app is specified in package.json * and for child-apps */ defaultTramvaiDependencies?: boolean; /** * @title automatically resolve requiredVersion for shared dependencies * @see https://webpack.js.org/plugins/module-federation-plugin/#requiredversion * @default true */ autoResolveSharedRequiredVersions?: boolean; /** * @title add chunks to preload as critical in-parallel with "platform.js" * @description this option is useful when you need to create async boundary for app dependencies. * More info - https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption * @default [] */ criticalChunks?: string[]; /** * @title list of the dependencies that will be shared * @default [] */ deps?: Array; }; } export interface ApplicationProject extends BaseProject { name: string; type: 'application'; /** * @title Path to the root directory, where `tramvai.config.ts` is located * @default process.cwd() */ rootDir?: string; /** * @title Path to the project source code directory, relative to `rootDir` * @default "src" */ sourceDir?: string; /** * @title Path to the project entry point, relative to `rootDir` + `sourceDir` * If absolute path is provided, it will be used as is * @default "index.ts" */ entryFile?: string; output?: { server?: string; client?: string; static?: string; }; fileSystemPages?: FileSystemPagesOptions; /** * @title File-System Papi Routes source directory * @default "api" */ fileSystemPapiDir?: string; experiments?: ApplicationExperiments; postcss?: PostcssOptions; polyfill?: string; modernPolyfill?: string; dedupe?: DedupeOptions; integrity?: IntegrityOptions | boolean; } export interface ChildAppProject extends BaseProject { name: string; type: 'child-app'; /** * @title Path to the root directory, where `tramvai.config.ts` is located * @default process.cwd() */ rootDir?: string; /** * @title Path to the project source code directory, relative to `rootDir` * If absolute path is provided, it will be used as is * @default "src" */ sourceDir?: string; /** * @title Path to the project entry point, relative to `rootDir` + `sourceDir` * If absolute path is provided, it will be used as is * @default "index.ts" */ entryFile?: string; experiments?: ChildAppExperiments; output?: string; postcss?: PostcssOptions; dedupe?: DedupeOptions; } export type Configuration = { projects: Record; plugins?: Array; }; export type SerializableConfig = { projectType: string; projectName: string; staticPort: number; staticHost: string; port: number; host: string; httpProtocol: string; assetsPrefix: string | null; output: { server: string; client: string; static: string; }; }; export type Extension = ({ config, parameters, project, }: { config: ConfigService; parameters: InputParameters; project: Project; }) => Value; type ExtensionToken = Record>; export interface ConfigurationExtensions { } export declare const CONFIG_SERVICE_TOKEN: ConfigService & { __type?: "base token" | undefined; }; export declare const INPUT_PARAMETERS_TOKEN: InputParameters & { __type?: "base token" | undefined; }; export declare const CONFIGURATION_EXTENSION_TOKEN: ExtensionToken & { __type?: "multi token" | undefined; }; export declare class ConfigService { #private; constructor(parameters: InputParameters, extraConfiguration?: Partial); initialize(): Promise; loadExtensions(extensions: ExtensionToken[]): void; get extensions(): { [key in keyof ConfigurationExtensions]: () => ReturnType; }; get rawConfiguration(): Configuration; get extraConfiguration(): Partial; get configPath(): string | null; get plugins(): (string | TramvaiPlugin)[]; get buildType(): "all" | "client" | "server"; get noServerRebuild(): boolean; get noClientRebuild(): boolean; get staticPort(): number; get port(): number; get runtimeEnv(): Record; get staticHost(): string; get host(): string; get benchmark(): boolean; get analyze(): false | "bundle" | "whybundled" | "statoscope" | "rsdoctor" | "stats"; get httpProtocol(): "https" | "http"; get rootDir(): string; get resolveSymlinks(): boolean; get debug(): string | false; get serverHot(): boolean | undefined; get debugBuild(): string | false; get verboseLogging(): boolean; get sourceDir(): string; get entryFile(): string; get showProgress(): boolean; get showBanner(): boolean; get mode(): "development" | "production"; get projectName(): string; get projectVersion(): string; get projectType(): "application" | "child-app"; get assetsPrefix(): string | null; get polyfill(): string | null | undefined; get modernPolyfill(): string | null | undefined; get outputServer(): string; get outputServerFilename(): string; get outputClient(): string; get outputStatic(): string; get fileSystemPages(): FileSystemPagesOptions | null; get fileSystemPapiDir(): string | null; get postcss(): PostcssOptions | null; get experiments(): ApplicationExperiments | ChildAppExperiments; get dedupe(): DedupeOptions; get svgo(): BaseProject['svgo']; get integrity(): {} | null; get clientSourceMap(): boolean; get serverSourceMap(): boolean; get hotRefresh(): BaseProject['hotRefresh']; get liveReload(): BaseProject['liveReload']; get writeToDisk(): BaseProject['writeToDisk']; get imageOptimization(): { /** * Enable image-minimizer-webpack-plugin */ enabled?: boolean | undefined; /** * Options to image-minimizer-webpack-plugin */ options?: PluginOptions | undefined; }; get generateDataQaTag(): boolean; get enableFillDeclareActionNamePlugin(): boolean; get transpilation(): { include: { development: string[] | "all" | "only-modern" | "none"; production: "all" | "only-modern"; }; }; get fileCache(): boolean; get cacheProfile(): boolean; get disableServerRunnerWaiting(): boolean; get disableWebSocketServer(): boolean; get deprecatedLessSupport(): boolean; get shared(): BaseProject['shared']; get buildPath(): string; private isChildAppProject; private getSourceMap; readConfigurationFile({ rootDir }: { rootDir: string; }): Promise; getParams(): InputParameters; updateParam(name: K, value: InputParameters[K]): void; dehydrate(): SerializableConfig; } export {}; //# sourceMappingURL=config-service.d.ts.map