@@ -6,19 +6,20 @@ The `web` generator transforms JSX AST entries into complete web bundles, produc
66
77The ` web ` generator accepts the following configuration options:
88
9- | Name | Type | Default | Description |
10- | ----------------- | --------- | --------------------------------------------- | --------------------------------------------------------------------- |
11- | ` output ` | ` string ` | - | The directory where HTML, JavaScript, and CSS files will be written |
12- | ` templatePath ` | ` string ` | ` 'template.html' ` | Path to the HTML template file |
13- | ` project ` | ` string ` | ` 'Node.js' ` | Project name used in page titles and the version selector |
14- | ` title ` | ` string ` | ` '{project} v{version} Documentation' ` | Title template for HTML pages (supports ` {project} ` , ` {version} ` ) |
15- | ` useAbsoluteURLs ` | ` boolean ` | ` false ` | When ` true ` , all internal links use absolute URLs based on ` baseURL ` |
16- | ` editURL ` | ` string ` | ` '${GITHUB_EDIT_URL}/doc/api{path}.md' ` | URL template for "edit this page" links |
17- | ` pageURL ` | ` string ` | ` '{baseURL}/latest-{version}/api{path}.html' ` | URL template for documentation page links |
18- | ` head ` | ` object ` | See below | Configurable ` <meta> ` , ` <link> ` , and raw markup for the document head |
19- | ` lightningcss ` | ` object ` | ` {} ` | Options spread into LightningCSS while bundling CSS (see below) |
20- | ` imports ` | ` object ` | See below | Object mapping ` #theme/ ` aliases to component paths for customization |
21- | ` virtualImports ` | ` object ` | ` {} ` | Additional virtual module mappings merged into the build |
9+ | Name | Type | Default | Description |
10+ | ----------------- | --------- | --------------------------------------------- | ------------------------------------------------------------------------ |
11+ | ` output ` | ` string ` | - | The directory where HTML, JavaScript, and CSS files will be written |
12+ | ` templatePath ` | ` string ` | ` 'template.html' ` | Path to the HTML template file |
13+ | ` project ` | ` string ` | ` 'Node.js' ` | Project name used in page titles and the version selector |
14+ | ` title ` | ` string ` | ` '{project} v{version} Documentation' ` | Title template for HTML pages (supports ` {project} ` , ` {version} ` ) |
15+ | ` useAbsoluteURLs ` | ` boolean ` | ` false ` | When ` true ` , all internal links use absolute URLs based on ` baseURL ` |
16+ | ` editURL ` | ` string ` | ` '${GITHUB_EDIT_URL}/doc/api{path}.md' ` | URL template for "edit this page" links |
17+ | ` pageURL ` | ` string ` | ` '{baseURL}/latest-{version}/api{path}.html' ` | URL template for documentation page links |
18+ | ` head ` | ` object ` | See below | Configurable ` <meta> ` , ` <link> ` , and raw markup for the document head |
19+ | ` lightningcss ` | ` object ` | ` {} ` | Options spread into LightningCSS while bundling CSS (see below) |
20+ | ` imports ` | ` object ` | See below | Object mapping ` #theme/ ` aliases to component paths for customization |
21+ | ` virtualImports ` | ` object ` | ` {} ` | Additional virtual module mappings merged into the build |
22+ | ` rolldown ` | ` object ` | ` {} ` | Options merged into the Rolldown build — extra plugins, etc. (see below) |
2223
2324#### ` head `
2425
@@ -95,6 +96,63 @@ To apply more than one visitor, compose them with LightningCSS's
9596
9697[ lightningcss ] : https://lightningcss.dev/transforms.html
9798
99+ #### Custom Rolldown options
100+
101+ The ` rolldown ` object is merged into the [ Rolldown] [ rolldown ] ` build ` call used
102+ for ** both** the client and server bundles, so you can register extra plugins,
103+ inject compile-time constants, add module aliases, or set any other Rolldown
104+ option. The same config is applied to both builds — branch inside a plugin (or
105+ read the ` SERVER ` /` CLIENT ` defines) if you need per-target behavior.
106+
107+ The merge follows these rules:
108+
109+ - ** ` plugins ` ** are registered after the built-in virtual-module plugin (so
110+ they see the in-memory entry modules) and before the CSS loader.
111+ - ** ` transform.define ` ** and ** ` resolve.alias ` ** are merged key-by-key, so you
112+ can add entries without dropping the generator's. The built-in ` SERVER ` /
113+ ` CLIENT ` defines and the ` react ` /` react-dom ` → ` preact/compat ` aliases
114+ (plus anything from ` imports ` ) always win.
115+ - ** All other options** (e.g. ` output.minify ` , ` treeshake ` , ` external ` ,
116+ ` platform ` , ` logLevel ` ) override the generator's defaults.
117+ - ** ` input ` ** and the built-in plugins are managed by the generator and cannot
118+ be overridden.
119+
120+ > Functions (plugins, hooks, alias resolvers, etc.) are allowed here because the
121+ > ` web ` generator runs entirely on the main thread. Unlike the chunked
122+ > generators, its config is never serialized to a worker, so values that can't
123+ > be structured-cloned are safe. Keep this in mind if ` web ` ever gains parallel
124+ > processing: function-valued options would then need a serializable form.
125+
126+ ``` js
127+ // doc-kit.config.mjs
128+ import myRolldownPlugin from ' ./my-rolldown-plugin.mjs' ;
129+
130+ export default {
131+ web: {
132+ rolldown: {
133+ // Register additional plugins (run after the built-in ones).
134+ plugins: [myRolldownPlugin ()],
135+
136+ // Inject extra compile-time constants (merged with SERVER/CLIENT).
137+ transform: {
138+ define: {
139+ ' process.env.ANALYTICS_ID' : JSON .stringify (' UA-XXXXX' ),
140+ },
141+ },
142+
143+ // Extend module resolution with custom aliases.
144+ resolve: {
145+ alias: {
146+ ' @components' : ' ./src/components' ,
147+ },
148+ },
149+ },
150+ },
151+ };
152+ ```
153+
154+ [ rolldown ] : https://rolldown.rs/
155+
98156#### Default ` imports `
99157
100158| Alias | Default | Description |
0 commit comments