From 13cd10b5f9e9fccd56b979268d6527223675be4e Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 23 Oct 2024 17:55:17 +0800 Subject: [PATCH] feat: improve JSDoc for `output` and `html` configurations --- packages/core/src/types/config.ts | 82 +++++++++++++++++++++--- website/docs/en/config/html/template.mdx | 1 - website/docs/zh/config/html/template.mdx | 1 - 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/packages/core/src/types/config.ts b/packages/core/src/types/config.ts index d434ac0f12..aab0b6b656 100644 --- a/packages/core/src/types/config.ts +++ b/packages/core/src/types/config.ts @@ -708,13 +708,25 @@ export type FilenameConfig = { }; export type DataUriLimit = { - /** The data URI limit of the SVG image. */ + /** + * The data URI limit of the SVG image. + * @default 4096 + */ svg?: number; - /** The data URI limit of the font file. */ + /** + * The data URI limit of the font file. + * @default 4096 + */ font?: number; - /** The data URI limit of non-SVG images. */ + /** + * The data URI limit of non-SVG images. + * @default 4096 + */ image?: number; - /** The data URI limit of media resources such as videos. */ + /** + * The data URI limit of media resources such as videos. + * @default 4096 + */ media?: number; }; @@ -727,7 +739,15 @@ export type NormalizedDataUriLimit = Required; export type Polyfill = 'usage' | 'entry' | 'off'; export type SourceMap = { + /** + * The source map type for JavaScript files. + * @default isDev ? 'cheap-module-source-map' : false + */ js?: Rspack.Configuration['devtool']; + /** + * Whether to generate source map for CSS files. + * @default false + */ css?: boolean; }; @@ -741,26 +761,32 @@ export type CSSModulesLocalsConvention = export type CSSModules = { /** * Allows CSS Modules to be automatically enabled based on their filenames. + * @default true */ auto?: CSSLoaderModulesOptions['auto']; /** * Allows exporting names from global class names, so you can use them via import. + * @default false */ exportGlobals?: boolean; /** * Style of exported class names. + * @default 'camelCase' */ exportLocalsConvention?: CSSModulesLocalsConvention; /** * Set the local ident name of CSS Modules. + * @default isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]' */ localIdentName?: string; /** * Controls the level of compilation applied to the input styles. + * @default 'local' */ mode?: CSSLoaderModulesOptions['mode']; /** * Whether to enable ES modules named export for locals. + * @default false */ namedExport?: boolean; }; @@ -807,6 +833,7 @@ export interface OutputConfig { /** * At build time, prevent some `import` dependencies from being packed into bundles in your code, and instead fetch them externally at runtime. * For more information, please see: [Rspack Externals](https://rspack.dev/config/externals) + * @default undefined */ externals?: Externals; /** @@ -826,12 +853,14 @@ export interface OutputConfig { charset?: Charset; /** * Configure how the polyfill is injected. + * @default 'off' */ polyfill?: Polyfill; /** * When using CDN in the production, * you can use this option to set the URL prefix of static assets, * similar to the output.publicPath config of webpack. + * @default `server.base` */ assetPrefix?: string; /** @@ -845,6 +874,7 @@ export interface OutputConfig { * comment in CSS that contains @license or @preserve or that starts with //! or /\*!. * These comments are preserved in output files by default since that follows the intent * of the original authors of the code. + * @default 'linked' */ legalComments?: LegalComments; /** @@ -858,30 +888,44 @@ export interface OutputConfig { cssModules?: CSSModules; /** * Whether to disable code minification in production build. + * @default true */ minify?: Minify; /** * Whether to generate manifest file. + * @default false */ manifest?: string | boolean; /** - * Whether to generate source map files, and which format of source map to generate + * Whether to generate source map files, and which format of source map to generate. + * + * @default + * ```js + * const defaultSourceMap = { + * js: isDev ? 'cheap-module-source-map' : false, + * css: false, + * }; + * ``` */ sourceMap?: SourceMap; /** * Whether to add filename hash after production build. + * @default true */ filenameHash?: boolean | string; /** * Whether to inline output scripts files (.js files) into HTML with `