@dtwo/schema 3.0.0-rc.14 → 3.1.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,1231 +17,1387 @@ import type { Options } from 'webpack-dev-middleware'
17
17
  import type { IncomingMessage, ServerResponse } from 'http'
18
18
  import type { MiddlewareOptions, ClientOptions } from 'webpack-hot-middleware'
19
19
  export interface ConfigSchema {
20
- /**
21
- * Configure Dtwo component auto-registration.
22
- * Any components in the directories configured here can be used throughout your pages, layouts (and other components) without needing to explicitly import them.
20
+ /**
21
+ * Configure Dtwo component auto-registration.
22
+ *
23
+ * Any components in the directories configured here can be used throughout your pages, layouts (and other components) without needing to explicitly import them.
24
+ *
25
+ *
26
+ * @see https://dtwojs.web.app/docs/guide/directory-structure/components
27
+ */
28
+ components: boolean | ComponentsOptions | ComponentsOptions['dirs'],
29
+
30
+ /**
31
+ * Configure how Dtwo auto-imports composables into your application.
32
+ *
33
+ *
34
+ * @see [Dtwo 3 documentation](https://dtwojs.web.app/docs/guide/directory-structure/composables)
35
+ */
36
+ imports: ImportsOptions,
37
+
38
+ /**
39
+ * Whether to use the kdu-router integration in Dtwo 3. If you do not provide a value it will be enabled if you have a `pages/` directory in your source folder.
40
+ *
41
+ */
42
+ pages: boolean,
43
+
44
+ /**
45
+ * Manually disable dtwo telemetry.
46
+ *
47
+ */
48
+ telemetry: boolean,
49
+
50
+ /**
51
+ * Kdu.js config
52
+ *
53
+ */
54
+ kdu: {
55
+ /**
56
+ * Options for the Kdu compiler that will be passed at build time.
57
+ *
23
58
  *
24
- * @default {{ dirs: [`~/components`] }}
59
+ * @see [documentation](https://kdu-js.web.app/api/application.html#app-config-compileroptions)
25
60
  */
26
- components: boolean | ComponentsOptions | ComponentsOptions['dirs'],
27
-
28
- /** Configure how Dtwo auto-imports composables into your application. */
29
- imports: ImportsOptions,
30
-
31
- /** Whether to use the kdu-router integration in Dtwo 3. If you do not provide a value it will be enabled if you have a `pages/` directory in your source folder. */
32
- pages: boolean,
33
-
34
- /** Manually disable dtwo telemetry. */
35
- telemetry: boolean,
36
-
37
- /** Kdu.js config */
38
- kdu: {
39
- /**
40
- * Options for the Kdu compiler that will be passed at build time.
41
- *
42
- * @see [documentation](https://kdu-js.web.app/api/application.html#app-config-compileroptions)
43
- */
44
- compilerOptions: CompilerOptions,
45
- },
61
+ compilerOptions: CompilerOptions,
62
+ },
63
+
64
+ /**
65
+ * Dtwo App configuration.
66
+ *
67
+ */
68
+ app: {
69
+ /**
70
+ * The base path of your Dtwo application.
71
+ *
72
+ * This can be set at runtime by setting the DTWO_APP_BASE_URL environment variable.
73
+ *
74
+ * @default "/"
75
+ *
76
+ * @example
77
+ * ```bash
78
+ * DTWO_APP_BASE_URL=/prefix/ node .output/server/index.mjs
79
+ * ```
80
+ */
81
+ baseURL: string,
46
82
 
47
- /** Dtwo App configuration. */
48
- app: {
49
- /**
50
- * The base path of your Dtwo application.
51
- * This can be set at runtime by setting the DTWO_APP_BASE_URL environment variable.
52
- * @default "/"
53
- *
54
- * @example
55
- * ```bash
56
- * DTWO_APP_BASE_URL=/prefix/ node .output/server/index.mjs
57
- * ```
58
- */
59
- baseURL: string,
60
-
61
- /**
62
- * The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime.
63
- * @default "/_dtwo/"
64
- */
65
- buildAssetsDir: string,
66
-
67
- /**
68
- * An absolute URL to serve the public folder from (production-only).
69
- * This can be set to a different value at runtime by setting the `DTWO_APP_CDN_URL` environment variable.
70
- * @default ""
71
- *
72
- * @example
73
- * ```bash
74
- * DTWO_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
75
- * ```
76
- */
77
- cdnURL: string,
78
-
79
- /**
80
- * Set default configuration for `<head>` on every page.
81
- *
82
- * @example
83
- * ```js
84
- * app: {
85
- * head: {
86
- * meta: [
87
- * // <meta name="viewport" content="width=device-width, initial-scale=1">
88
- * { name: 'viewport', content: 'width=device-width, initial-scale=1' }
89
- * ],
90
- * script: [
91
- * // <script src="https://myawesome-lib.js"></script>
92
- * { src: 'https://awesome-lib.js' }
93
- * ],
94
- * link: [
95
- * // <link rel="stylesheet" href="https://myawesome-lib.css">
96
- * { rel: 'stylesheet', href: 'https://awesome-lib.css' }
97
- * ],
98
- * // please note that this is an area that is likely to change
99
- * style: [
100
- * // <style type="text/css">:root { color: red }</style>
101
- * { children: ':root { color: red }', type: 'text/css' }
102
- * ],
103
- * noscript: [
104
- * // <noscript>Javascript is required</noscript>
105
- * { children: 'Javascript is required' }
106
- * ]
107
- * }
108
- * }
109
- * ```
110
- */
111
- head: DtwoAppConfig['head'],
112
-
113
- /**
114
- * Default values for layout transitions.
115
- * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
116
- * @default false
117
- *
118
- * @see https://kdu-js.web.app/api/built-in-components.html#transition
119
- */
120
- layoutTransition: DtwoAppConfig['layoutTransition'],
121
-
122
- /**
123
- * Default values for page transitions.
124
- * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
125
- * @default false
126
- *
127
- * @see https://kdu-js.web.app/api/built-in-components.html#transition
128
- */
129
- pageTransition: DtwoAppConfig['pageTransition'],
130
-
131
- /**
132
- * Default values for KeepAlive configuration between pages.
133
- * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
134
- * @default false
135
- *
136
- * @see https://kdu-js.web.app/api/built-in-components.html#keepalive
137
- */
138
- keepalive: DtwoAppConfig['keepalive'],
139
-
140
- /**
141
- * Customize Dtwo root element id.
142
- * @default "__dtwo"
143
- */
144
- rootId: string,
145
-
146
- /**
147
- * Customize Dtwo root element tag.
148
- * @default "div"
149
- */
150
- rootTag: string,
151
- },
83
+ /**
84
+ * The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime.
85
+ *
86
+ * @default "/_dtwo/"
87
+ */
88
+ buildAssetsDir: string,
152
89
 
153
90
  /**
154
- * An array of dtwo app plugins.
155
- * Each plugin can be a string (which can be an absolute or relative path to a file). If it ends with `.client` or `.server` then it will be automatically loaded only in the appropriate context.
156
- * It can also be an object with `src` and `mode` keys.
91
+ * An absolute URL to serve the public folder from (production-only).
92
+ *
93
+ * This can be set to a different value at runtime by setting the `DTWO_APP_CDN_URL` environment variable.
94
+ *
95
+ * @default ""
157
96
  *
158
97
  * @example
159
- * ```js
160
- * plugins: [
161
- * '~/plugins/foo.client.js', // only in client side
162
- * '~/plugins/bar.server.js', // only in server side
163
- * '~/plugins/baz.js', // both client & server
164
- * { src: '~/plugins/both-sides.js' },
165
- * { src: '~/plugins/client-only.js', mode: 'client' }, // only on client side
166
- * { src: '~/plugins/server-only.js', mode: 'server' } // only on server side
167
- * ]
98
+ * ```bash
99
+ * DTWO_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
168
100
  * ```
169
101
  */
170
- plugins: (DtwoPlugin | string)[],
102
+ cdnURL: string,
171
103
 
172
104
  /**
173
- * You can define the CSS files/modules/libraries you want to set globally (included in every page).
174
- * Dtwo will automatically guess the file type by its extension and use the appropriate pre-processor. You will still need to install the required loader if you need to use them.
105
+ * Set default configuration for `<head>` on every page.
106
+ *
175
107
  *
176
108
  * @example
177
109
  * ```js
178
- * css: [
179
- * // Load a Node.js module directly (here it's a Sass file).
180
- * 'bulma',
181
- * // CSS file in the project
182
- * '@/assets/css/main.css',
183
- * // SCSS file in the project
184
- * '@/assets/css/main.scss'
185
- * ]
110
+ * app: {
111
+ * head: {
112
+ * meta: [
113
+ * // <meta name="viewport" content="width=device-width, initial-scale=1">
114
+ * { name: 'viewport', content: 'width=device-width, initial-scale=1' }
115
+ * ],
116
+ * script: [
117
+ * // <script src="https://myawesome-lib.js"></script>
118
+ * { src: 'https://awesome-lib.js' }
119
+ * ],
120
+ * link: [
121
+ * // <link rel="stylesheet" href="https://myawesome-lib.css">
122
+ * { rel: 'stylesheet', href: 'https://awesome-lib.css' }
123
+ * ],
124
+ * // please note that this is an area that is likely to change
125
+ * style: [
126
+ * // <style type="text/css">:root { color: red }</style>
127
+ * { children: ':root { color: red }', type: 'text/css' }
128
+ * ],
129
+ * noscript: [
130
+ * // <noscript>JavaScript is required</noscript>
131
+ * { children: 'JavaScript is required' }
132
+ * ]
133
+ * }
134
+ * }
186
135
  * ```
187
136
  */
188
- css: string[],
189
-
190
- /**
191
- * The builder to use for bundling the Kdu part of your application.
192
- * @default "@dtwo/wite-builder"
193
- */
194
- builder: 'wite' | 'webpack' | { bundle: (dtwo: Dtwo) => Promise<void> },
195
-
196
- /** Whether to generate sourcemaps. */
197
- sourcemap: boolean | { server?: boolean, client?: boolean },
198
-
199
- /** Shared build configuration. */
200
- build: {
201
- /**
202
- * If you want to transpile specific dependencies with Babel, you can add them here. Each item in transpile can be a package name, a function, a string or regex object matching the dependency's file name.
203
- * You can also use a function to conditionally transpile. The function will receive an object ({ isDev, isServer, isClient, isModern, isLegacy }).
204
- *
205
- * @example
206
- * ```js
207
- * transpile: [({ isLegacy }) => isLegacy && 'ky']
208
- * ```
209
- */
210
- transpile: Array<string | RegExp | Function>,
211
-
212
- /**
213
- * You can provide your own templates which will be rendered based on Dtwo configuration. This feature is specially useful for using with modules.
214
- * Templates are rendered using [`lodash.template`](https://lodash.com/docs/4.17.15#template).
215
- *
216
- * @example
217
- * ```js
218
- * templates: [
219
- * {
220
- * src: '~/modules/support/plugin.js', // `src` can be absolute or relative
221
- * dst: 'support.js', // `dst` is relative to project `.dtwo` dir
222
- * options: {
223
- * // Options are provided to template as `options` key
224
- * live_chat: false
225
- * }
226
- * }
227
- * ]
228
- * ```
229
- */
230
- templates: Array<any>,
231
-
232
- /**
233
- * Dtwo uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
234
- * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for wite](https://github.com/btd/rollup-plugin-visualizer#options).
235
- * @default false
236
- *
237
- * @example
238
- * ```js
239
- * analyze: {
240
- * analyzerMode: 'static'
241
- * }
242
- * ```
243
- */
244
- analyze: boolean | BundleAnalyzerPlugin.Options | PluginVisualizerOptions,
245
- },
137
+ head: DtwoAppConfig['head'],
246
138
 
247
139
  /**
248
- * Extend project from multiple local or remote sources.
249
- * Value should be either a string or array of strings pointing to source directories or config path relative to current config.
250
- * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
140
+ * Default values for layout transitions.
141
+ *
142
+ * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
143
+ *
144
+ * @default false
145
+ *
146
+ * @see https://kdu-js.web.app/api/built-in-components.html#transition
251
147
  */
252
- extends: string|string[],
148
+ layoutTransition: DtwoAppConfig['layoutTransition'],
253
149
 
254
150
  /**
255
- * Extend project from a local or remote source.
256
- * Value should be a string pointing to source directory or config path relative to current config.
257
- * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
258
- * @default null
151
+ * Default values for page transitions.
152
+ *
153
+ * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
154
+ *
155
+ * @default false
156
+ *
157
+ * @see https://kdu-js.web.app/api/built-in-components.html#transition
259
158
  */
260
- theme: string,
159
+ pageTransition: DtwoAppConfig['pageTransition'],
261
160
 
262
161
  /**
263
- * Define the root directory of your application.
264
- * This property can be overwritten (for example, running `dtwo ./my-app/` will set the `rootDir` to the absolute path of `./my-app/` from the current/working directory.
265
- * It is normally not needed to configure this option.
266
- * @default "/<rootDir>"
162
+ * Default values for KeepAlive configuration between pages.
163
+ *
164
+ * This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
165
+ *
166
+ * @default false
167
+ *
168
+ * @see https://kdu-js.web.app/api/built-in-components.html#keepalive
267
169
  */
268
- rootDir: string,
170
+ keepalive: DtwoAppConfig['keepalive'],
269
171
 
270
172
  /**
271
- * Define the workspace directory of your application.
272
- * Often this is used when in a monorepo setup. Dtwo will attempt to detect your workspace directory automatically, but you can override it here.
273
- * It is normally not needed to configure this option.
274
- * @default "/<rootDir>"
173
+ * Customize Dtwo root element id.
174
+ *
175
+ * @default "__dtwo"
275
176
  */
276
- workspaceDir: string,
177
+ rootId: string,
277
178
 
278
179
  /**
279
- * Define the source directory of your Dtwo application.
280
- * If a relative path is specified, it will be relative to the `rootDir`.
281
- * @default "/<rootDir>"
180
+ * Customize Dtwo root element tag.
181
+ *
182
+ * @default "div"
183
+ */
184
+ rootTag: string,
185
+ },
186
+
187
+ /**
188
+ * An array of dtwo app plugins.
189
+ *
190
+ * Each plugin can be a string (which can be an absolute or relative path to a file). If it ends with `.client` or `.server` then it will be automatically loaded only in the appropriate context.
191
+ * It can also be an object with `src` and `mode` keys.
192
+ *
193
+ *
194
+ * @note Plugins are also auto-registered from the `~/plugins` directory
195
+ * and these plugins do not need to be listed in `dtwo.config` unless you
196
+ * need to customize their order. All plugins are deduplicated by their src path.
197
+ *
198
+ * @see https://dtwojs.web.app/docs/guide/directory-structure/plugins
199
+ *
200
+ * @example
201
+ * ```js
202
+ * plugins: [
203
+ * '~/plugins/foo.client.js', // only in client side
204
+ * '~/plugins/bar.server.js', // only in server side
205
+ * '~/plugins/baz.js', // both client & server
206
+ * { src: '~/plugins/both-sides.js' },
207
+ * { src: '~/plugins/client-only.js', mode: 'client' }, // only on client side
208
+ * { src: '~/plugins/server-only.js', mode: 'server' } // only on server side
209
+ * ]
210
+ * ```
211
+ */
212
+ plugins: (DtwoPlugin | string)[],
213
+
214
+ /**
215
+ * You can define the CSS files/modules/libraries you want to set globally (included in every page).
216
+ *
217
+ * Dtwo will automatically guess the file type by its extension and use the appropriate pre-processor. You will still need to install the required loader if you need to use them.
218
+ *
219
+ *
220
+ * @example
221
+ * ```js
222
+ * css: [
223
+ * // Load a Node.js module directly (here it's a Sass file).
224
+ * 'bulma',
225
+ * // CSS file in the project
226
+ * '@/assets/css/main.css',
227
+ * // SCSS file in the project
228
+ * '@/assets/css/main.scss'
229
+ * ]
230
+ * ```
231
+ */
232
+ css: string[],
233
+
234
+ /**
235
+ * The builder to use for bundling the Kdu part of your application.
236
+ *
237
+ * @default "@dtwo/wite-builder"
238
+ */
239
+ builder: 'wite' | 'webpack' | { bundle: (dtwo: Dtwo) => Promise<void> },
240
+
241
+ /**
242
+ * Whether to generate sourcemaps.
243
+ *
244
+ */
245
+ sourcemap: boolean | { server?: boolean, client?: boolean },
246
+
247
+ /**
248
+ * Shared build configuration.
249
+ *
250
+ */
251
+ build: {
252
+ /**
253
+ * If you want to transpile specific dependencies with Babel, you can add them here. Each item in transpile can be a package name, a function, a string or regex object matching the dependency's file name.
254
+ *
255
+ * You can also use a function to conditionally transpile. The function will receive an object ({ isDev, isServer, isClient, isModern, isLegacy }).
256
+ *
282
257
  *
283
258
  * @example
284
259
  * ```js
285
- * export default {
286
- * srcDir: 'src/'
287
- * }
288
- * ```
289
- * This would work with the following folder structure:
290
- * ```bash
291
- * -| app/
292
- * ---| node_modules/
293
- * ---| dtwo.config.js
294
- * ---| package.json
295
- * ---| src/
296
- * ------| assets/
297
- * ------| components/
298
- * ------| layouts/
299
- * ------| middleware/
300
- * ------| pages/
301
- * ------| plugins/
302
- * ------| static/
303
- * ------| store/
304
- * ------| server/
260
+ * transpile: [({ isLegacy }) => isLegacy && 'ky']
305
261
  * ```
306
262
  */
307
- srcDir: string,
263
+ transpile: Array<string | RegExp | ((ctx: { isClient?: boolean; isServer?: boolean; isDev: boolean }) => string | RegExp | false)>,
308
264
 
309
265
  /**
310
- * Define the server directory of your Dtwo application, where Hole routes, middleware and plugins are kept.
311
- * If a relative path is specified, it will be relative to your `rootDir`.
312
- * @default "/<rootDir>/server"
313
- */
314
- serverDir: string,
315
-
316
- /**
317
- * Define the directory where your built Dtwo files will be placed.
318
- * Many tools assume that `.dtwo` is a hidden directory (because it starts with a `.`). If that is a problem, you can use this option to prevent that.
319
- * @default "/<rootDir>/.dtwo"
266
+ * You can provide your own templates which will be rendered based on Dtwo configuration. This feature is specially useful for using with modules.
267
+ *
268
+ * Templates are rendered using [`lodash.template`](https://lodash.com/docs/4.17.15#template).
269
+ *
320
270
  *
321
271
  * @example
322
272
  * ```js
323
- * export default {
324
- * buildDir: 'dtwo-build'
325
- * }
273
+ * templates: [
274
+ * {
275
+ * src: '~/modules/support/plugin.js', // `src` can be absolute or relative
276
+ * dst: 'support.js', // `dst` is relative to project `.dtwo` dir
277
+ * options: {
278
+ * // Options are provided to template as `options` key
279
+ * live_chat: false
280
+ * }
281
+ * }
282
+ * ]
326
283
  * ```
327
284
  */
328
- buildDir: string,
285
+ templates: Array<any>,
329
286
 
330
287
  /**
331
- * Used to set the modules directories for path resolving (for example, webpack's `resolveLoading`, `nodeExternals` and `postcss`).
332
- * The configuration path is relative to `options.rootDir` (default is current working directory).
333
- * Setting this field may be necessary if your project is organized as a yarn workspace-styled mono-repository.
334
- * @default ["/<rootDir>/node_modules","D:/Workspace/ORGs/d2js/dtwo/packages/schema/node_modules"]
288
+ * Dtwo uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
289
+ *
290
+ * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for wite](https://github.com/btd/rollup-plugin-visualizer#options).
291
+ *
292
+ * @default false
335
293
  *
336
294
  * @example
337
295
  * ```js
338
- * export default {
339
- * modulesDir: ['../../node_modules']
296
+ * analyze: {
297
+ * analyzerMode: 'static'
340
298
  * }
341
299
  * ```
342
300
  */
343
- modulesDir: Array<string>,
301
+ analyze: boolean | BundleAnalyzerPlugin.Options | PluginVisualizerOptions,
302
+ },
303
+
304
+ /**
305
+ * Extend project from multiple local or remote sources.
306
+ *
307
+ * Value should be either a string or array of strings pointing to source directories or config path relative to current config.
308
+ * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
309
+ *
310
+ */
311
+ extends: string|string[],
312
+
313
+ /**
314
+ * Extend project from a local or remote source.
315
+ *
316
+ * Value should be a string pointing to source directory or config path relative to current config.
317
+ * You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
318
+ *
319
+ * @default null
320
+ */
321
+ theme: string,
322
+
323
+ /**
324
+ * Define the root directory of your application.
325
+ *
326
+ * This property can be overwritten (for example, running `dtwo ./my-app/` will set the `rootDir` to the absolute path of `./my-app/` from the current/working directory.
327
+ * It is normally not needed to configure this option.
328
+ *
329
+ * @default "/<rootDir>"
330
+ */
331
+ rootDir: string,
332
+
333
+ /**
334
+ * Define the workspace directory of your application.
335
+ *
336
+ * Often this is used when in a monorepo setup. Dtwo will attempt to detect your workspace directory automatically, but you can override it here.
337
+ * It is normally not needed to configure this option.
338
+ *
339
+ * @default "/<rootDir>"
340
+ */
341
+ workspaceDir: string,
342
+
343
+ /**
344
+ * Define the source directory of your Dtwo application.
345
+ *
346
+ * If a relative path is specified, it will be relative to the `rootDir`.
347
+ *
348
+ * @default "/<rootDir>"
349
+ *
350
+ * @example
351
+ * ```js
352
+ * export default {
353
+ * srcDir: 'src/'
354
+ * }
355
+ * ```
356
+ * This would work with the following folder structure:
357
+ * ```bash
358
+ * -| app/
359
+ * ---| node_modules/
360
+ * ---| dtwo.config.js
361
+ * ---| package.json
362
+ * ---| src/
363
+ * ------| assets/
364
+ * ------| components/
365
+ * ------| layouts/
366
+ * ------| middleware/
367
+ * ------| pages/
368
+ * ------| plugins/
369
+ * ------| static/
370
+ * ------| store/
371
+ * ------| server/
372
+ * ```
373
+ */
374
+ srcDir: string,
375
+
376
+ /**
377
+ * Define the server directory of your Dtwo application, where Hole routes, middleware and plugins are kept.
378
+ *
379
+ * If a relative path is specified, it will be relative to your `rootDir`.
380
+ *
381
+ * @default "/<rootDir>/server"
382
+ */
383
+ serverDir: string,
384
+
385
+ /**
386
+ * Define the directory where your built Dtwo files will be placed.
387
+ *
388
+ * Many tools assume that `.dtwo` is a hidden directory (because it starts with a `.`). If that is a problem, you can use this option to prevent that.
389
+ *
390
+ * @default "/<rootDir>/.dtwo"
391
+ *
392
+ * @example
393
+ * ```js
394
+ * export default {
395
+ * buildDir: 'dtwo-build'
396
+ * }
397
+ * ```
398
+ */
399
+ buildDir: string,
400
+
401
+ /**
402
+ * Used to set the modules directories for path resolving (for example, webpack's `resolveLoading`, `nodeExternals` and `postcss`).
403
+ *
404
+ * The configuration path is relative to `options.rootDir` (default is current working directory).
405
+ * Setting this field may be necessary if your project is organized as a yarn workspace-styled mono-repository.
406
+ *
407
+ * @default ["/<rootDir>/node_modules","D:/Workspace/ORGs/d2js/dtwo/packages/schema/node_modules"]
408
+ *
409
+ * @example
410
+ * ```js
411
+ * export default {
412
+ * modulesDir: ['../../node_modules']
413
+ * }
414
+ * ```
415
+ */
416
+ modulesDir: Array<string>,
417
+
418
+ /**
419
+ * Whether Dtwo is running in development mode.
420
+ *
421
+ * Normally, you should not need to set this.
422
+ *
423
+ * @default false
424
+ */
425
+ dev: boolean,
426
+
427
+ /**
428
+ * Whether your app is being unit tested.
429
+ *
430
+ * @default false
431
+ */
432
+ test: boolean,
433
+
434
+ /**
435
+ * Set to `true` to enable debug mode.
436
+ *
437
+ * At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
438
+ *
439
+ * @default false
440
+ */
441
+ debug: boolean,
442
+
443
+ /**
444
+ * Whether to enable rendering of HTML - either dynamically (in server mode) or at generate time. If set to `false` and combined with `static` target, generated pages will simply display a loading screen with no content.
445
+ *
446
+ * @default true
447
+ */
448
+ ssr: boolean,
449
+
450
+ /**
451
+ * Modules are Dtwo extensions which can extend its core functionality and add endless integrations.
452
+ *
453
+ * Each module is either a string (which can refer to a package, or be a path to a file), a tuple with the module as first string and the options as a second object, or an inline module function.
454
+ * Dtwo tries to resolve each item in the modules array using node require path (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
455
+ *
456
+ *
457
+ * @note Modules are executed sequentially so the order is important.
458
+ *
459
+ * @example
460
+ * ```js
461
+ * modules: [
462
+ * // Using package name
463
+ * '@dtwojs/axios',
464
+ * // Relative to your project srcDir
465
+ * '~/modules/awesome.js',
466
+ * // Providing options
467
+ * ['@dtwojs/google-analytics', { ua: 'X1234567' }],
468
+ * // Inline definition
469
+ * function () {}
470
+ * ]
471
+ * ```
472
+ */
473
+ modules: (DtwoModule | string | [DtwoModule | string, Record<string, any>])[],
474
+
475
+ /**
476
+ * Customize default directory structure used by Dtwo.
477
+ *
478
+ * It is better to stick with defaults unless needed.
479
+ *
480
+ */
481
+ dir: {
482
+ /**
483
+ * The assets directory (aliased as `~assets` in your build).
484
+ *
485
+ * @default "assets"
486
+ */
487
+ assets: string,
344
488
 
345
489
  /**
346
- * Whether Dtwo is running in development mode.
347
- * Normally, you should not need to set this.
348
- * @default false
490
+ * The layouts directory, each file of which will be auto-registered as a Dtwo layout.
491
+ *
492
+ * @default "layouts"
349
493
  */
350
- dev: boolean,
494
+ layouts: string,
351
495
 
352
496
  /**
353
- * Whether your app is being unit tested.
354
- * @default false
497
+ * The middleware directory, each file of which will be auto-registered as a Dtwo middleware.
498
+ *
499
+ * @default "middleware"
355
500
  */
356
- test: boolean,
501
+ middleware: string,
357
502
 
358
503
  /**
359
- * Set to `true` to enable debug mode.
360
- * At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
361
- * @default false
504
+ * The directory which will be processed to auto-generate your application page routes.
505
+ *
506
+ * @default "pages"
362
507
  */
363
- debug: boolean,
508
+ pages: string,
364
509
 
365
510
  /**
366
- * Whether to enable rendering of HTML - either dynamically (in server mode) or at generate time. If set to `false` and combined with `static` target, generated pages will simply display a loading screen with no content.
367
- * @default true
511
+ * The plugins directory, each file of which will be auto-registered as a Dtwo plugin.
512
+ *
513
+ * @default "plugins"
368
514
  */
369
- ssr: boolean,
515
+ plugins: string,
370
516
 
371
517
  /**
372
- * Modules are Dtwo extensions which can extend its core functionality and add endless integrations.
373
- * Each module is either a string (which can refer to a package, or be a path to a file), a tuple with the module as first string and the options as a second object, or an inline module function.
374
- * Dtwo tries to resolve each item in the modules array using node require path (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
518
+ * The directory containing your static files, which will be directly accessible via the Dtwo server and copied across into your `dist` folder when your app is generated.
375
519
  *
376
- * @note Modules are executed sequentially so the order is important.
520
+ * @default "public"
521
+ */
522
+ public: string,
523
+
524
+ /**
525
+ * @default "public"
377
526
  *
378
- * @example
379
- * ```js
380
- * modules: [
381
- * // Using package name
382
- * '@dtwojs/axios',
383
- * // Relative to your project srcDir
384
- * '~/modules/awesome.js',
385
- * // Providing options
386
- * ['@dtwojs/google-analytics', { ua: 'X1234567' }],
387
- * // Inline definition
388
- * function () {}
389
- * ]
390
- * ```
527
+ * @deprecated use `dir.public` option instead
391
528
  */
392
- modules: (DtwoModule | string | [DtwoModule | string, Record<string, any>])[],
393
-
394
- /**
395
- * Customize default directory structure used by Dtwo.
396
- * It is better to stick with defaults unless needed.
397
- */
398
- dir: {
399
- /**
400
- * The assets directory (aliased as `~assets` in your build).
401
- * @default "assets"
402
- */
403
- assets: string,
404
-
405
- /**
406
- * The layouts directory, each file of which will be auto-registered as a Dtwo layout.
407
- * @default "layouts"
408
- */
409
- layouts: string,
410
-
411
- /**
412
- * The middleware directory, each file of which will be auto-registered as a Dtwo middleware.
413
- * @default "middleware"
414
- */
415
- middleware: string,
416
-
417
- /**
418
- * The directory which will be processed to auto-generate your application page routes.
419
- * @default "pages"
420
- */
421
- pages: string,
422
-
423
- /**
424
- * The plugins directory, each file of which will be auto-registered as a Dtwo plugin.
425
- * @default "plugins"
426
- */
427
- plugins: string,
428
-
429
- /**
430
- * The directory containing your static files, which will be directly accessible via the Dtwo server and copied across into your `dist` folder when your app is generated.
431
- * @default "public"
432
- */
433
- public: string,
434
-
435
- /**
436
- * @default "public"
437
- *
438
- * @deprecated use `dir.public` option instead
439
- */
440
- static: string,
441
- },
529
+ static: string,
530
+ },
531
+
532
+ /**
533
+ * The extensions that should be resolved by the Dtwo resolver.
534
+ *
535
+ * @default [".js",".jsx",".mjs",".ts",".tsx",".kdu"]
536
+ */
537
+ extensions: Array<string>,
538
+
539
+ /**
540
+ * You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
541
+ *
542
+ *
543
+ * @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
544
+ * your alias by prefixing it with `~`.
545
+ *
546
+ * @note These aliases will be automatically added to the generated `.dtwo/tsconfig.json` so you can get full
547
+ * type support and path auto-complete. In case you need to extend options provided by `./.dtwo/tsconfig.json`
548
+ * further, make sure to add them here or within the `typescript.tsConfig` property in `dtwo.config`.
549
+ *
550
+ * @example
551
+ * ```js
552
+ * export default {
553
+ * alias: {
554
+ * 'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
555
+ * 'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
556
+ * 'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
557
+ * }
558
+ * }
559
+ * ```
560
+ *
561
+ * ```html
562
+ * <template>
563
+ * <img src="~images/main-bg.jpg">
564
+ * </template>
565
+ *
566
+ * <script>
567
+ * import data from 'data/test.json'
568
+ * </script>
569
+ *
570
+ * <style>
571
+ * // Uncomment the below
572
+ * //@import '~style/variables.scss';
573
+ * //@import '~style/utils.scss';
574
+ * //@import '~style/base.scss';
575
+ * body {
576
+ * background-image: url('~images/main-bg.jpg');
577
+ * }
578
+ * </style>
579
+ * ```
580
+ */
581
+ alias: Record<string, string>,
582
+
583
+ /**
584
+ * Pass options directly to `node-ignore` (which is used by Dtwo to ignore files).
585
+ *
586
+ *
587
+ * @see [node-ignore](https://github.com/kaelzhang/node-ignore)
588
+ *
589
+ * @example
590
+ * ```js
591
+ * ignoreOptions: {
592
+ * ignorecase: false
593
+ * }
594
+ * ```
595
+ */
596
+ ignoreOptions: any,
597
+
598
+ /**
599
+ * Any file in `pages/`, `layouts/`, `middleware/` or `store/` will be ignored during building if its filename starts with the prefix specified by `ignorePrefix`.
600
+ *
601
+ * @default "-"
602
+ */
603
+ ignorePrefix: string,
604
+
605
+ /**
606
+ * More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
607
+ *
608
+ * @default ["**\/*.stories.{js,ts,jsx,tsx}","**\/*.{spec,test}.{js,ts,jsx,tsx}","**\/*.d.ts",".output","**\/-*.*"]
609
+ */
610
+ ignore: Array<string>,
611
+
612
+ /**
613
+ * The watchers property lets you overwrite watchers configuration in your `dtwo.config`.
614
+ *
615
+ */
616
+ watchers: {
617
+ /**
618
+ * An array of event types, which, when received, will cause the watcher to restart.
619
+ *
620
+ */
621
+ rewatchOnRawEvents: any,
442
622
 
443
623
  /**
444
- * The extensions that should be resolved by the Dtwo resolver.
445
- * @default [".js",".jsx",".mjs",".ts",".tsx",".kdu"]
624
+ * `watchOptions` to pass directly to webpack.
625
+ *
626
+ *
627
+ * @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
446
628
  */
447
- extensions: Array<string>,
629
+ webpack: {
630
+ /** @default 1000 */
631
+ aggregateTimeout: number,
632
+ },
448
633
 
449
634
  /**
450
- * You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
635
+ * Options to pass directly to `chokidar`.
636
+ *
451
637
  *
452
- * @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
453
- * your alias by prefixing it with `~`.
638
+ * @see [chokidar](https://github.com/paulmillr/chokidar#api)
639
+ */
640
+ chokidar: {
641
+ /** @default true */
642
+ ignoreInitial: boolean,
643
+ },
644
+ },
645
+
646
+ /**
647
+ * Hooks are listeners to Dtwo events that are typically used in modules, but are also available in `dtwo.config`.
648
+ *
649
+ * Internally, hooks follow a naming pattern using colons (e.g., build:done).
650
+ * For ease of configuration, you can also structure them as an hierarchical object in `dtwo.config` (as below).
651
+ *
652
+ *
653
+ * @example
654
+ * ```js'node:fs'
655
+ * import fs from 'node:fs'
656
+ * import path from 'node:path'
657
+ * export default {
658
+ * hooks: {
659
+ * build: {
660
+ * done(builder) {
661
+ * const extraFilePath = path.join(
662
+ * builder.dtwo.options.buildDir,
663
+ * 'extra-file'
664
+ * )
665
+ * fs.writeFileSync(extraFilePath, 'Something extra')
666
+ * }
667
+ * }
668
+ * }
669
+ * }
670
+ * ```
671
+ */
672
+ hooks: DtwoHooks,
673
+
674
+ /**
675
+ * Runtime config allows passing dynamic config and environment variables to the Dtwo app context.
676
+ *
677
+ * The value of this object is accessible from server only using `useRuntimeConfig`.
678
+ * It mainly should hold _private_ configuration which is not exposed on the frontend. This could include a reference to your API secret tokens.
679
+ * Anything under `public` and `app` will be exposed to the frontend as well.
680
+ * Values are automatically replaced by matching env variables at runtime, e.g. setting an environment variable `DTWO_API_KEY=my-api-key DTWO_PUBLIC_BASE_URL=/foo/` would overwrite the two values in the example below.
681
+ *
682
+ *
683
+ * @example
684
+ * ```js
685
+ * export default {
686
+ * runtimeConfig: {
687
+ * apiKey: '' // Default to an empty string, automatically set at runtime using process.env.DTWO_API_KEY
688
+ * public: {
689
+ * baseURL: '' // Exposed to the frontend as well.
690
+ * }
691
+ * }
692
+ * }
693
+ * ```
694
+ */
695
+ runtimeConfig: RuntimeConfig,
696
+
697
+ /**
698
+ * Additional app configuration
699
+ *
700
+ * For programmatic usage and type support, you can directly provide app config with this option. It will be merged with `app.config` file as default value.
701
+ *
702
+ */
703
+ appConfig: AppConfig,
704
+
705
+ devServer: {
706
+ /**
707
+ * Whether to enable HTTPS.
454
708
  *
455
- * @note These aliases will be automatically added to the generated `.dtwo/tsconfig.json` so you can get full
456
- * type support and path auto-complete. In case you need to extend options provided by `./.dtwo/tsconfig.json`
457
- * further, make sure to add them here or within the `typescript.tsConfig` property in `dtwo.config`.
709
+ * @default false
458
710
  *
459
711
  * @example
460
- * ```js
712
+ * ```
713
+ * import { fileURLToPath } from 'node:url'
461
714
  * export default {
462
- * alias: {
463
- * 'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
464
- * 'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
465
- * 'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
715
+ * server: {
716
+ * https: {
717
+ * key: fs.readFileSync(fileURLToPath(new URL('./server.key', import.meta.url))),
718
+ * cert: fs.readFileSync(fileURLToPath(new URL('./server.crt', import.meta.url)))
719
+ * }
466
720
  * }
467
721
  * }
468
722
  * ```
469
- *
470
- * ```html
471
- * <template>
472
- * <img src="~images/main-bg.jpg">
473
- * </template>
474
- *
475
- * <script>
476
- * import data from 'data/test.json'
477
- * </script>
478
- *
479
- * <style>
480
- * // Uncomment the below
481
- * //@import '~style/variables.scss';
482
- * //@import '~style/utils.scss';
483
- * //@import '~style/base.scss';
484
- * body {
485
- * background-image: url('~images/main-bg.jpg');
486
- * }
487
- * </style>
488
- * ```
489
723
  */
490
- alias: Record<string, string>,
724
+ https: false | { key: string; cert: string },
491
725
 
492
726
  /**
493
- * Pass options directly to `node-ignore` (which is used by Dtwo to ignore files).
727
+ * Dev server listening port
494
728
  *
495
- * @see [node-ignore](https://github.com/kaelzhang/node-ignore)
496
- *
497
- * @example
498
- * ```js
499
- * ignoreOptions: {
500
- * ignorecase: false
501
- * }
502
- * ```
729
+ * @default 3000
503
730
  */
504
- ignoreOptions: any,
731
+ port: number,
505
732
 
506
733
  /**
507
- * Any file in `pages/`, `layouts/`, `middleware/` or `store/` will be ignored during building if its filename starts with the prefix specified by `ignorePrefix`.
508
- * @default "-"
734
+ * Dev server listening host
735
+ *
736
+ * @default "localhost"
509
737
  */
510
- ignorePrefix: string,
738
+ host: string,
511
739
 
512
740
  /**
513
- * More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
514
- * @default ["**\/*.stories.{js,ts,jsx,tsx}","**\/*.{spec,test}.{js,ts,jsx,tsx}","**\/*.d.ts",".output","**\/-*.*"]
741
+ * Listening dev server url
742
+ *
743
+ * @default "http://localhost:3000"
515
744
  */
516
- ignore: Array<string>,
517
-
518
- /** The watchers property lets you overwrite watchers configuration in your `dtwo.config`. */
519
- watchers: {
520
- /** An array of event types, which, when received, will cause the watcher to restart. */
521
- rewatchOnRawEvents: any,
522
-
523
- /**
524
- * `watchOptions` to pass directly to webpack.
525
- *
526
- * @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
527
- */
528
- webpack: {
529
- /** @default 1000 */
530
- aggregateTimeout: number,
531
- },
532
-
533
- /**
534
- * Options to pass directly to `chokidar`.
535
- *
536
- * @see [chokidar](https://github.com/paulmillr/chokidar#api)
537
- */
538
- chokidar: {
539
- /** @default true */
540
- ignoreInitial: boolean,
541
- },
542
- },
745
+ url: string,
746
+ },
543
747
 
748
+ experimental: {
544
749
  /**
545
- * Hooks are listeners to Dtwo events that are typically used in modules, but are also available in `dtwo.config`.
546
- * Internally, hooks follow a naming pattern using colons (e.g., build:done).
547
- * For ease of configuration, you can also structure them as an hierarchical object in `dtwo.config` (as below).
750
+ * Set to true to generate an async entry point for the Kdu bundle (for module federation support).
548
751
  *
549
- * @example
550
- * ```js'node:fs'
551
- * import fs from 'node:fs'
552
- * import path from 'node:path'
553
- * export default {
554
- * hooks: {
555
- * build: {
556
- * done(builder) {
557
- * const extraFilePath = path.join(
558
- * builder.dtwo.options.buildDir,
559
- * 'extra-file'
560
- * )
561
- * fs.writeFileSync(extraFilePath, 'Something extra')
562
- * }
563
- * }
564
- * }
565
- * }
566
- * ```
752
+ * @default false
567
753
  */
568
- hooks: DtwoHooks,
754
+ asyncEntry: boolean,
569
755
 
570
756
  /**
571
- * Runtime config allows passing dynamic config and environment variables to the Dtwo app context.
572
- * The value of this object is accessible from server only using `useRuntimeConfig`.
573
- * It mainly should hold _private_ configuration which is not exposed on the frontend. This could include a reference to your API secret tokens.
574
- * Anything under `public` and `app` will be exposed to the frontend as well.
575
- * Values are automatically replaced by matching env variables at runtime, e.g. setting an environment variable `DTWO_API_KEY=my-api-key DTWO_PUBLIC_BASE_URL=/foo/` would overwrite the two values in the example below.
757
+ * Enable Kdu's reactivity transform
576
758
  *
577
- * @example
578
- * ```js
579
- * export default {
580
- * runtimeConfig: {
581
- * apiKey: '' // Default to an empty string, automatically set at runtime using process.env.DTWO_API_KEY
582
- * public: {
583
- * baseURL: '' // Exposed to the frontend as well.
584
- * }
585
- * }
586
- * }
587
- * ```
759
+ * @default false
760
+ *
761
+ * @see https://kdu-js.web.app/guide/extras/reactivity-transform.html
588
762
  */
589
- runtimeConfig: RuntimeConfig,
590
-
591
- /**
592
- * Additional app configuration
593
- * For programmatic usage and type support, you can directly provide app config with this option. It will be merged with `app.config` file as default value.
594
- */
595
- appConfig: AppConfig,
596
-
597
- devServer: {
598
- /**
599
- * Whether to enable HTTPS.
600
- * @default false
601
- *
602
- * @example
603
- * ```
604
- * import { fileURLToPath } from 'node:url'
605
- * export default {
606
- * server: {
607
- * https: {
608
- * key: fs.readFileSync(fileURLToPath(new URL('./server.key', import.meta.url))),
609
- * cert: fs.readFileSync(fileURLToPath(new URL('./server.crt', import.meta.url)))
610
- * }
611
- * }
612
- * }
613
- * ```
614
- */
615
- https: false | { key: string; cert: string },
616
-
617
- /**
618
- * Dev server listening port
619
- * @default 3000
620
- */
621
- port: number,
622
-
623
- /**
624
- * Dev server listening host
625
- * @default "localhost"
626
- */
627
- host: string,
628
-
629
- /**
630
- * Listening dev server url
631
- * @default "http://localhost:3000"
632
- */
633
- url: string,
634
- },
763
+ reactivityTransform: boolean,
635
764
 
636
- experimental: {
637
- /**
638
- * Set to true to generate an async entry point for the Kdu bundle (for module federation support).
639
- * @default false
640
- */
641
- asyncEntry: boolean,
642
-
643
- /**
644
- * Enable Kdu's reactivity transform
645
- * @default false
646
- *
647
- * @see https://kdu-js.web.app/guide/extras/reactivity-transform.html
648
- */
649
- reactivityTransform: boolean,
650
-
651
- /**
652
- * Externalize `kdu`, `@kdujs/*` and `kdu-router` when building.
653
- * @default true
654
- */
655
- externalKdu: boolean,
656
-
657
- /**
658
- * Tree shakes contents of client-only components from server bundle.
659
- * @default true
660
- */
661
- treeshakeClientOnly: boolean,
662
-
663
- /**
664
- * Use wite-node for on-demand server chunk loading
665
- * @default true
666
- *
667
- * @deprecated use `wite.devBundler: 'wite-node'`
668
- */
669
- witeNode: boolean,
670
-
671
- /**
672
- * Split server bundle into multiple chunks and dynamically import them.
673
- * @default true
674
- */
675
- witeServerDynamicImports: boolean,
676
-
677
- /**
678
- * Inline styles when rendering HTML (currently wite only).
679
- * You can also pass a function that receives the path of a Kdu component and returns a boolean indicating whether to inline the styles for that component.
680
- * @default true
681
- */
682
- inlineSSRStyles: boolean | ((id?: string) => boolean),
683
-
684
- /**
685
- * Turn off rendering of Dtwo scripts and JS resource hints.
686
- * @default false
687
- */
688
- noScripts: boolean,
689
-
690
- /**
691
- * When this option is enabled (by default) payload of pages generated with `dtwo generate` are extracted
692
- * @default false
693
- */
694
- payloadExtraction: boolean,
695
-
696
- /**
697
- * Enable cross-origin prefetch using the Speculation Rules API.
698
- * @default false
699
- */
700
- crossOriginPrefetch: boolean,
701
-
702
- /**
703
- * Write early hints when using node server.
704
- * @default false
705
- *
706
- * @note nginx does not support 103 Early hints in the current version.
707
- */
708
- writeEarlyHints: boolean,
709
- },
765
+ /**
766
+ * Externalize `kdu`, `@kdujs/*` and `kdu-router` when building.
767
+ *
768
+ * @default true
769
+ */
770
+ externalKdu: boolean,
710
771
 
711
- generate: {
712
- /**
713
- * The routes to generate.
714
- * If you are using the crawler, this will be only the starting point for route generation. This is often necessary when using dynamic routes.
715
- * It can be an array or a function.
716
- *
717
- * @example
718
- * ```js
719
- * routes: ['/users/1', '/users/2', '/users/3']
720
- * ```
721
- *
722
- * You can pass a function that returns a promise or a function that takes a callback. It should
723
- * return an array of strings or objects with `route` and (optional) `payload` keys.
724
- *
725
- * @example
726
- * ```js
727
- * export default {
728
- * generate: {
729
- * async routes() {
730
- * const res = await axios.get('https://my-api/users')
731
- * return res.data.map(user => ({ route: '/users/' + user.id, payload: user }))
732
- * }
733
- * }
734
- * }
735
- * ```
736
- * Or instead:
737
- * ```js
738
- * export default {
739
- * generate: {
740
- * routes(callback) {
741
- * axios
742
- * .get('https://my-api/users')
743
- * .then(res => {
744
- * const routes = res.data.map(user => '/users/' + user.id)
745
- * callback(null, routes)
746
- * })
747
- * .catch(callback)
748
- * }
749
- * }
750
- * }
751
- * ```
752
- *
753
- * If `routes()` returns a payload, it can be accessed from the Dtwo context.
754
- *
755
- * @example
756
- * ```js
757
- * export default {
758
- * async useAsyncData ({ params, error, payload }) {
759
- * if (payload) return { user: payload }
760
- * else return { user: await backend.fetchUser(params.id) }
761
- * }
762
- * }
763
- * ```
764
- */
765
- routes: Array<any>,
766
-
767
- /** An array of string or regular expressions that will prevent generation of routes matching them. The routes will still be accessible when `fallback` is set. */
768
- exclude: Array<any>,
769
- },
772
+ /**
773
+ * Tree shakes contents of client-only components from server bundle.
774
+ *
775
+ * @default true
776
+ */
777
+ treeshakeClientOnly: boolean,
770
778
 
771
779
  /**
772
- * @default 3
780
+ * Use wite-node for on-demand server chunk loading
781
+ *
782
+ * @default true
773
783
  *
774
- * @private
784
+ * @deprecated use `wite.devBundler: 'wite-node'`
775
785
  */
776
- _majorVersion: number,
786
+ witeNode: boolean,
777
787
 
778
788
  /**
779
- * @default false
789
+ * Split server bundle into multiple chunks and dynamically import them.
780
790
  *
781
- * @private
791
+ * @default true
782
792
  */
783
- _legacyGenerate: boolean,
793
+ witeServerDynamicImports: boolean,
784
794
 
785
795
  /**
786
- * @default false
796
+ * Inline styles when rendering HTML (currently wite only).
797
+ *
798
+ * You can also pass a function that receives the path of a Kdu component and returns a boolean indicating whether to inline the styles for that component.
787
799
  *
788
- * @private
800
+ * @default true
789
801
  */
790
- _start: boolean,
802
+ inlineSSRStyles: boolean | ((id?: string) => boolean),
791
803
 
792
804
  /**
793
- * @default false
805
+ * Turn off rendering of Dtwo scripts and JS resource hints.
794
806
  *
795
- * @private
807
+ * @default false
796
808
  */
797
- _build: boolean,
809
+ noScripts: boolean,
798
810
 
799
811
  /**
812
+ * When this option is enabled (by default) payload of pages generated with `dtwo generate` are extracted
813
+ *
800
814
  * @default false
815
+ */
816
+ payloadExtraction: boolean,
817
+
818
+ /**
819
+ * Enable cross-origin prefetch using the Speculation Rules API.
801
820
  *
802
- * @private
821
+ * @default false
803
822
  */
804
- _generate: boolean,
823
+ crossOriginPrefetch: boolean,
805
824
 
806
825
  /**
826
+ * Write early hints when using node server.
827
+ *
807
828
  * @default false
808
829
  *
809
- * @private
830
+ * @note nginx does not support 103 Early hints in the current version.
810
831
  */
811
- _prepare: boolean,
832
+ writeEarlyHints: boolean,
812
833
 
813
834
  /**
835
+ * Experimental component islands support with <DtwoIsland> and .island.kdu files.
836
+ *
814
837
  * @default false
838
+ */
839
+ componentIslands: boolean,
840
+
841
+ /**
842
+ * Enable experimental config schema support
815
843
  *
816
- * @private
844
+ * @default false
817
845
  */
818
- _cli: boolean,
846
+ configSchema: boolean,
847
+ },
819
848
 
849
+ generate: {
820
850
  /**
851
+ * The routes to generate.
852
+ *
853
+ * If you are using the crawler, this will be only the starting point for route generation. This is often necessary when using dynamic routes.
854
+ * It is preferred to use `hole.prerender.routes`.
821
855
  *
822
- * @private
856
+ *
857
+ * @example
858
+ * ```js
859
+ * routes: ['/users/1', '/users/2', '/users/3']
860
+ * ```
823
861
  */
824
- _requiredModules: any,
862
+ routes: Array<any>,
825
863
 
826
864
  /**
865
+ * This option is no longer used. Instead, use `hole.prerender.ignore`.
866
+ *
867
+ */
868
+ exclude: Array<any>,
869
+ },
870
+
871
+ /**
872
+ * @default 3
873
+ *
874
+ * @private
875
+ */
876
+ _majorVersion: number,
877
+
878
+ /**
879
+ * @default false
880
+ *
881
+ * @private
882
+ */
883
+ _legacyGenerate: boolean,
884
+
885
+ /**
886
+ * @default false
887
+ *
888
+ * @private
889
+ */
890
+ _start: boolean,
891
+
892
+ /**
893
+ * @default false
894
+ *
895
+ * @private
896
+ */
897
+ _build: boolean,
898
+
899
+ /**
900
+ * @default false
901
+ *
902
+ * @private
903
+ */
904
+ _generate: boolean,
905
+
906
+ /**
907
+ * @default false
908
+ *
909
+ * @private
910
+ */
911
+ _prepare: boolean,
912
+
913
+ /**
914
+ * @default false
915
+ *
916
+ * @private
917
+ */
918
+ _cli: boolean,
919
+
920
+ /**
921
+ *
922
+ * @private
923
+ */
924
+ _requiredModules: any,
925
+
926
+ /**
927
+ *
928
+ * @private
929
+ */
930
+ _dtwoConfigFile: any,
931
+
932
+ /**
933
+ *
934
+ * @private
935
+ */
936
+ _dtwoConfigFiles: Array<any>,
937
+
938
+ /**
939
+ * @default ""
940
+ *
941
+ * @private
942
+ */
943
+ appDir: string,
944
+
945
+ /**
946
+ *
947
+ * @private
948
+ */
949
+ _installedModules: Array<any>,
950
+
951
+ /**
952
+ *
953
+ * @private
954
+ */
955
+ _modules: Array<any>,
956
+
957
+ /**
958
+ * Configuration for Hole.
959
+ *
960
+ *
961
+ * @see https://holepack.web.app/config/
962
+ */
963
+ hole: HoleConfig,
964
+
965
+ /**
966
+ * Global route options applied to matching server routes.
967
+ *
968
+ *
969
+ * @experimental This is an experimental feature and API may change in the future.
970
+ *
971
+ * @see https://holepack.web.app/config/#routes
972
+ */
973
+ routeRules: HoleConfig['routeRules'],
974
+
975
+ /**
976
+ * Hole server handlers.
977
+ *
978
+ * Each handler accepts the following options: - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of https://github.com/unjs/radix3. - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
979
+ *
980
+ *
981
+ * @see https://dtwojs.web.app/docs/guide/directory-structure/server
982
+ *
983
+ * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Dtwo.
984
+ *
985
+ * @example
986
+ * ```js
987
+ * serverHandlers: [
988
+ * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
989
+ * ]
990
+ * ```
991
+ */
992
+ serverHandlers: HoleEventHandler[],
993
+
994
+ /**
995
+ * Hole development-only server handlers.
996
+ *
997
+ *
998
+ * @see https://holepack.web.app/guide/introduction/routing
999
+ */
1000
+ devServerHandlers: HoleDevEventHandler[],
1001
+
1002
+ postcss: {
1003
+ /**
1004
+ * Options for configuring PostCSS plugins.
1005
+ *
1006
+ * https://postcss.org/
827
1007
  *
828
- * @private
829
1008
  */
830
- _dtwoConfigFile: any,
1009
+ plugins: Record<string, any>,
1010
+ },
831
1011
 
1012
+ router: {
1013
+ /**
1014
+ * Additional options passed to `kdu-router`.
1015
+ *
1016
+ * Note: Only JSON serializable options should be passed by dtwo config.
1017
+ * For more control, you can use `app/router.options.ts` file.
1018
+ *
1019
+ *
1020
+ * @see [documentation](https://kdujs-router.web.app/api/interfaces/routeroptions.html).
1021
+ */
1022
+ options: import('../src/types/router').RouterConfigSerializable,
1023
+ },
1024
+
1025
+ /**
1026
+ * Configuration for Dtwo's TypeScript integration.
1027
+ *
1028
+ */
1029
+ typescript: {
832
1030
  /**
1031
+ * TypeScript comes with certain checks to give you more safety and analysis of your program. Once you’ve converted your codebase to TypeScript, you can start enabling these checks for greater safety. [Read More](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks)
833
1032
  *
834
- * @private
1033
+ * @default true
835
1034
  */
836
- _dtwoConfigFiles: Array<any>,
1035
+ strict: boolean,
837
1036
 
838
1037
  /**
839
- * @default ""
1038
+ * Include parent workspace in the Dtwo project. Mostly useful for themes and module authors.
840
1039
  *
841
- * @private
1040
+ * @default false
842
1041
  */
843
- appDir: string,
1042
+ includeWorkspace: boolean,
844
1043
 
845
1044
  /**
1045
+ * Enable build-time type checking.
846
1046
  *
847
- * @private
1047
+ * If set to true, this will type check in development. You can restrict this to build-time type checking by setting it to `build`. Requires to install `typescript` and `kdu-tsc` as dev dependencies.
1048
+ *
1049
+ * @default false
1050
+ *
1051
+ * @see https://dtwojs.web.app/docs/guide/concepts/typescript
848
1052
  */
849
- _installedModules: Array<any>,
1053
+ typeCheck: boolean | 'build',
850
1054
 
851
1055
  /**
1056
+ * You can extend generated `.dtwo/tsconfig.json` using this option.
852
1057
  *
853
- * @private
854
1058
  */
855
- _modules: Array<any>,
1059
+ tsConfig: readPackageJSON,
856
1060
 
857
1061
  /**
858
- * Configuration for Hole.
1062
+ * Generate a `*.kdu` shim.
1063
+ *
1064
+ * We recommend instead either enabling [**Take Over Mode**](https://kdu-js.web.app/guide/typescript/overview.html#kocan-takeover-mode) or adding TypeScript Kdu Plugin (Kocan)** 👉 [[Download](https://marketplace.visualstudio.com/items?itemName=Kdu-Code.vscode-typescript-kdu-plugin)].
1065
+ *
1066
+ * @default true
1067
+ */
1068
+ shim: boolean,
1069
+ },
1070
+
1071
+ /**
1072
+ * Configuration that will be passed directly to Wite.
1073
+ *
1074
+ * See https://witejs.web.app/config for more information. Please note that not all wite options are supported in Dtwo.
1075
+ *
1076
+ */
1077
+ wite: WiteConfig,
1078
+
1079
+ webpack: {
1080
+ /**
1081
+ * Dtwo uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
1082
+ *
1083
+ * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for wite](https://github.com/btd/rollup-plugin-visualizer#options).
859
1084
  *
860
- * @see https://holepack.web.app/config/
1085
+ * @default false
1086
+ *
1087
+ * @example
1088
+ * ```js
1089
+ * analyze: {
1090
+ * analyzerMode: 'static'
1091
+ * }
1092
+ * ```
861
1093
  */
862
- hole: HoleConfig,
1094
+ analyze: boolean | BundleAnalyzerPlugin.Options,
863
1095
 
864
1096
  /**
865
- * Global route options applied to matching server routes.
1097
+ * Enable the profiler in webpackbar.
1098
+ *
1099
+ * It is normally enabled by CLI argument `--profile`.
866
1100
  *
867
- * @experimental This is an experimental feature and API may change in the future.
1101
+ * @default false
868
1102
  *
869
- * @see https://holepack.web.app/config/#routes
1103
+ * @see [webpackbar](https://github.com/unjs/webpackbar#profile).
870
1104
  */
871
- routeRules: HoleConfig['routeRules'],
1105
+ profile: boolean,
872
1106
 
873
1107
  /**
874
- * Hole server handlers.
875
- * Each handler accepts the following options: - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of https://github.com/unjs/radix3. - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
1108
+ * Enables Common CSS Extraction using [Kdu Server Renderer guidelines](https://kdujs-ssr.web.app/guide/css.html).
876
1109
  *
877
- * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Dtwo.
1110
+ * Using [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/) under the hood, your CSS will be extracted into separate files, usually one per component. This allows caching your CSS and JavaScript separately and is worth trying if you have a lot of global or shared CSS.
1111
+ *
1112
+ * @default true
878
1113
  *
879
1114
  * @example
880
1115
  * ```js
881
- * serverHandlers: [
882
- * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
883
- * ]
1116
+ * export default {
1117
+ * webpack: {
1118
+ * extractCSS: true,
1119
+ * // or
1120
+ * extractCSS: {
1121
+ * ignoreOrder: true
1122
+ * }
1123
+ * }
1124
+ * }
1125
+ * ```
1126
+ *
1127
+ * If you want to extract all your CSS to a single file, there is a workaround for this.
1128
+ * However, note that it is not recommended to extract everything into a single file.
1129
+ * Extracting into multiple CSS files is better for caching and preload isolation. It
1130
+ * can also improve page performance by downloading and resolving only those resources
1131
+ * that are needed.
1132
+ *
1133
+ * @example
1134
+ * ```js
1135
+ * export default {
1136
+ * webpack: {
1137
+ * extractCSS: true,
1138
+ * optimization: {
1139
+ * splitChunks: {
1140
+ * cacheGroups: {
1141
+ * styles: {
1142
+ * name: 'styles',
1143
+ * test: /\.(css|kdu)$/,
1144
+ * chunks: 'all',
1145
+ * enforce: true
1146
+ * }
1147
+ * }
1148
+ * }
1149
+ * }
1150
+ * }
1151
+ * }
884
1152
  * ```
885
1153
  */
886
- serverHandlers: HoleEventHandler[],
1154
+ extractCSS: boolean | PluginOptions,
887
1155
 
888
1156
  /**
889
- * Hole development-only server handlers.
1157
+ * Enables CSS source map support (defaults to `true` in development).
890
1158
  *
891
- * @see https://holepack.web.app/guide/introduction/routing
1159
+ * @default false
892
1160
  */
893
- devServerHandlers: HoleDevEventHandler[],
1161
+ cssSourceMap: boolean,
894
1162
 
895
- postcss: {
896
- /**
897
- * Path to postcss config file.
898
- * @default false
899
- */
900
- config: boolean,
901
-
902
- /**
903
- * Options for configuring PostCSS plugins.
904
- * https://postcss.org/
905
- */
906
- plugins: Record<string, any>,
907
- },
1163
+ /**
1164
+ * The polyfill library to load to provide URL and URLSearchParams.
1165
+ *
1166
+ * Defaults to `'url'` ([see package](https://www.npmjs.com/package/url)).
1167
+ *
1168
+ * @default "url"
1169
+ */
1170
+ serverURLPolyfill: string,
908
1171
 
909
- router: {
910
- /**
911
- * Additional options passed to `kdu-router`.
912
- * Note: Only JSON serializable options should be passed by dtwo config.
913
- * For more control, you can use `app/router.options.ts` file.
914
- *
915
- * @see [documentation](https://kdujs-router.web.app/api/interfaces/routeroptions.html).
916
- */
917
- options: import('../src/types/router').RouterConfigSerializable,
918
- },
1172
+ /**
1173
+ * Customize bundle filenames.
1174
+ *
1175
+ * To understand a bit more about the use of manifests, take a look at [this webpack documentation](https://webpack.js.org/guides/code-splitting/).
1176
+ *
1177
+ *
1178
+ * @note Be careful when using non-hashed based filenames in production
1179
+ * as most browsers will cache the asset and not detect the changes on first load.
1180
+ *
1181
+ * This example changes fancy chunk names to numerical ids:
1182
+ *
1183
+ * @example
1184
+ * ```js
1185
+ * filenames: {
1186
+ * chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
1187
+ * }
1188
+ * ```
1189
+ */
1190
+ filenames: {
1191
+ app: () => any,
1192
+
1193
+ chunk: () => any,
1194
+
1195
+ css: () => any,
1196
+
1197
+ img: () => any,
1198
+
1199
+ font: () => any,
919
1200
 
920
- /** Configuration for Dtwo's TypeScript integration. */
921
- typescript: {
922
- /**
923
- * TypeScript comes with certain checks to give you more safety and analysis of your program. Once you’ve converted your codebase to TypeScript, you can start enabling these checks for greater safety. [Read More](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks)
924
- * @default true
925
- */
926
- strict: boolean,
927
-
928
- /**
929
- * Include parent workspace in the Dtwo project. Mostly useful for themes and module authors.
930
- * @default false
931
- */
932
- includeWorkspace: boolean,
933
-
934
- /**
935
- * Enable build-time type checking.
936
- * If set to true, this will type check in development. You can restrict this to build-time type checking by setting it to `build`. Requires to install `typescript` and `kdu-tsc` as dev dependencies.
937
- * @default false
938
- */
939
- typeCheck: boolean | 'build',
940
-
941
- /** You can extend generated `.dtwo/tsconfig.json` using this option. */
942
- tsConfig: readPackageJSON,
943
-
944
- /**
945
- * Generate a `*.kdu` shim.
946
- * We recommend instead either enabling [**Take Over Mode**](https://kdu-js.web.app/guide/typescript/overview.html#kocan-takeover-mode) or adding TypeScript Kdu Plugin (Kocan)** 👉 [[Download](https://marketplace.visualstudio.com/items?itemName=Kdu-Code.vscode-typescript-kdu-plugin)].
947
- * @default true
948
- */
949
- shim: boolean,
1201
+ video: () => any,
950
1202
  },
951
1203
 
952
1204
  /**
953
- * Configuration that will be passed directly to Wite.
954
- * See https://witejs.web.app/config for more information. Please note that not all wite options are supported in Dtwo.
1205
+ * Customize the options of Dtwo's integrated webpack loaders.
1206
+ *
955
1207
  */
956
- wite: WiteConfig,
1208
+ loaders: {
1209
+ file: {
1210
+ /** @default false */
1211
+ esModule: boolean,
1212
+ },
957
1213
 
958
- webpack: {
959
- /**
960
- * Dtwo uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
961
- * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for wite](https://github.com/btd/rollup-plugin-visualizer#options).
962
- * @default false
963
- *
964
- * @example
965
- * ```js
966
- * analyze: {
967
- * analyzerMode: 'static'
968
- * }
969
- * ```
970
- */
971
- analyze: boolean | BundleAnalyzerPlugin.Options,
972
-
973
- /**
974
- * Enable the profiler in webpackbar.
975
- * It is normally enabled by CLI argument `--profile`.
976
- * @default false
977
- *
978
- * @see [webpackbar](https://github.com/unjs/webpackbar#profile).
979
- */
980
- profile: boolean,
981
-
982
- /**
983
- * Enables Common CSS Extraction using [Kdu Server Renderer guidelines](https://kdujs-ssr.web.app/guide/css.html).
984
- * Using [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/) under the hood, your CSS will be extracted into separate files, usually one per component. This allows caching your CSS and JavaScript separately and is worth trying if you have a lot of global or shared CSS.
985
- * @default true
986
- *
987
- * @example
988
- * ```js
989
- * export default {
990
- * webpack: {
991
- * extractCSS: true,
992
- * // or
993
- * extractCSS: {
994
- * ignoreOrder: true
995
- * }
996
- * }
997
- * }
998
- * ```
999
- *
1000
- * If you want to extract all your CSS to a single file, there is a workaround for this.
1001
- * However, note that it is not recommended to extract everything into a single file.
1002
- * Extracting into multiple CSS files is better for caching and preload isolation. It
1003
- * can also improve page performance by downloading and resolving only those resources
1004
- * that are needed.
1005
- *
1006
- * @example
1007
- * ```js
1008
- * export default {
1009
- * webpack: {
1010
- * extractCSS: true,
1011
- * optimization: {
1012
- * splitChunks: {
1013
- * cacheGroups: {
1014
- * styles: {
1015
- * name: 'styles',
1016
- * test: /\.(css|kdu)$/,
1017
- * chunks: 'all',
1018
- * enforce: true
1019
- * }
1020
- * }
1021
- * }
1022
- * }
1023
- * }
1024
- * }
1025
- * ```
1026
- */
1027
- extractCSS: boolean | PluginOptions,
1028
-
1029
- /**
1030
- * Enables CSS source map support (defaults to `true` in development).
1031
- * @default false
1032
- */
1033
- cssSourceMap: boolean,
1034
-
1035
- /**
1036
- * The polyfill library to load to provide URL and URLSearchParams.
1037
- * Defaults to `'url'` ([see package](https://www.npmjs.com/package/url)).
1038
- * @default "url"
1039
- */
1040
- serverURLPolyfill: string,
1041
-
1042
- /**
1043
- * Customize bundle filenames.
1044
- * To understand a bit more about the use of manifests, take a look at [this webpack documentation](https://webpack.js.org/guides/code-splitting/).
1045
- *
1046
- * @note Be careful when using non-hashed based filenames in production
1047
- * as most browsers will cache the asset and not detect the changes on first load.
1048
- *
1049
- * This example changes fancy chunk names to numerical ids:
1050
- *
1051
- * @example
1052
- * ```js
1053
- * filenames: {
1054
- * chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
1055
- * }
1056
- * ```
1057
- */
1058
- filenames: {
1059
- app: () => any,
1060
-
1061
- chunk: () => any,
1062
-
1063
- css: () => any,
1064
-
1065
- img: () => any,
1066
-
1067
- font: () => any,
1068
-
1069
- video: () => any,
1070
- },
1214
+ fontUrl: {
1215
+ /** @default false */
1216
+ esModule: boolean,
1071
1217
 
1072
- /** Customize the options of Dtwo's integrated webpack loaders. */
1073
- loaders: {
1074
- file: {
1075
- /** @default false */
1076
- esModule: boolean,
1077
- },
1218
+ /** @default 1000 */
1219
+ limit: number,
1220
+ },
1078
1221
 
1079
- fontUrl: {
1080
- /** @default false */
1081
- esModule: boolean,
1222
+ imgUrl: {
1223
+ /** @default false */
1224
+ esModule: boolean,
1082
1225
 
1083
- /** @default 1000 */
1084
- limit: number,
1085
- },
1226
+ /** @default 1000 */
1227
+ limit: number,
1228
+ },
1086
1229
 
1087
- imgUrl: {
1088
- /** @default false */
1089
- esModule: boolean,
1230
+ pugPlain: any,
1090
1231
 
1091
- /** @default 1000 */
1092
- limit: number,
1093
- },
1232
+ kdu: {
1233
+ /** @default true */
1234
+ productionMode: boolean,
1094
1235
 
1095
- pugPlain: any,
1236
+ transformAssetUrls: {
1237
+ /** @default "src" */
1238
+ video: string,
1096
1239
 
1097
- kdu: {
1098
- /** @default true */
1099
- productionMode: boolean,
1240
+ /** @default "src" */
1241
+ source: string,
1100
1242
 
1101
- transformAssetUrls: {
1102
- /** @default "src" */
1103
- video: string,
1243
+ /** @default "src" */
1244
+ object: string,
1104
1245
 
1105
- /** @default "src" */
1106
- source: string,
1246
+ /** @default "src" */
1247
+ embed: string,
1248
+ },
1107
1249
 
1108
- /** @default "src" */
1109
- object: string,
1250
+ compilerOptions: {
1251
+ [key: string]: any
1252
+ },
1253
+ },
1110
1254
 
1111
- /** @default "src" */
1112
- embed: string,
1113
- },
1255
+ css: {
1256
+ /** @default 0 */
1257
+ importLoaders: number,
1114
1258
 
1115
- compilerOptions: {
1116
- [key: string]: any
1117
- },
1118
- },
1259
+ url: {
1260
+ filter: () => any,
1261
+ },
1119
1262
 
1120
- css: {
1121
- /** @default 0 */
1122
- importLoaders: number,
1263
+ /** @default false */
1264
+ esModule: boolean,
1265
+ },
1123
1266
 
1124
- url: {
1125
- filter: () => any,
1126
- },
1267
+ cssModules: {
1268
+ /** @default 0 */
1269
+ importLoaders: number,
1127
1270
 
1128
- /** @default false */
1129
- esModule: boolean,
1130
- },
1271
+ url: {
1272
+ filter: () => any,
1273
+ },
1131
1274
 
1132
- cssModules: {
1133
- /** @default 0 */
1134
- importLoaders: number,
1275
+ /** @default false */
1276
+ esModule: boolean,
1135
1277
 
1136
- url: {
1137
- filter: () => any,
1138
- },
1278
+ modules: {
1279
+ /** @default "[local]_[hash:base64:5]" */
1280
+ localIdentName: string,
1281
+ },
1282
+ },
1139
1283
 
1140
- /** @default false */
1141
- esModule: boolean,
1284
+ less: any,
1142
1285
 
1143
- modules: {
1144
- /** @default "[local]_[hash:base64:5]" */
1145
- localIdentName: string,
1146
- },
1147
- },
1286
+ sass: {
1287
+ sassOptions: {
1288
+ /** @default true */
1289
+ indentedSyntax: boolean,
1290
+ },
1291
+ },
1148
1292
 
1149
- less: any,
1293
+ scss: any,
1150
1294
 
1151
- sass: {
1152
- sassOptions: {
1153
- /** @default true */
1154
- indentedSyntax: boolean,
1155
- },
1156
- },
1295
+ stylus: any,
1157
1296
 
1158
- scss: any,
1297
+ kduStyle: any,
1298
+ },
1159
1299
 
1160
- stylus: any,
1300
+ /**
1301
+ * Add webpack plugins.
1302
+ *
1303
+ *
1304
+ * @example
1305
+ * ```js
1306
+ * import webpack from 'webpack'
1307
+ * import { version } from './package.json'
1308
+ * // ...
1309
+ * plugins: [
1310
+ * new webpack.DefinePlugin({
1311
+ * 'process.VERSION': version
1312
+ * })
1313
+ * ]
1314
+ * ```
1315
+ */
1316
+ plugins: Array<any>,
1161
1317
 
1162
- kduStyle: any,
1163
- },
1318
+ /**
1319
+ * Terser plugin options.
1320
+ *
1321
+ * Set to false to disable this plugin, or pass an object of options.
1322
+ *
1323
+ *
1324
+ * @see [terser-webpack-plugin documentation](https://github.com/webpack-contrib/terser-webpack-plugin).
1325
+ *
1326
+ * @note Enabling sourceMap will leave `//# sourceMappingURL` linking comment at
1327
+ * the end of each output file if webpack `config.devtool` is set to `source-map`.
1328
+ */
1329
+ terser: false | BasePluginOptions & DefinedDefaultMinimizerAndOptions<any>,
1164
1330
 
1165
- /**
1166
- * Add webpack plugins.
1167
- *
1168
- * @example
1169
- * ```js
1170
- * import webpack from 'webpack'
1171
- * import { version } from './package.json'
1172
- * // ...
1173
- * plugins: [
1174
- * new webpack.DefinePlugin({
1175
- * 'process.VERSION': version
1176
- * })
1177
- * ]
1178
- * ```
1179
- */
1180
- plugins: Array<any>,
1181
-
1182
- /**
1183
- * Terser plugin options.
1184
- * Set to false to disable this plugin, or pass an object of options.
1185
- *
1186
- * @see [terser-webpack-plugin documentation](https://github.com/webpack-contrib/terser-webpack-plugin).
1187
- *
1188
- * @note Enabling sourceMap will leave `//# sourceMappingURL` linking comment at
1189
- * the end of each output file if webpack `config.devtool` is set to `source-map`.
1190
- */
1191
- terser: false | BasePluginOptions & DefinedDefaultMinimizerAndOptions<any>,
1192
-
1193
- /**
1194
- * Hard-replaces `typeof process`, `typeof window` and `typeof document` to tree-shake bundle.
1195
- * @default false
1196
- */
1197
- aggressiveCodeRemoval: boolean,
1198
-
1199
- /**
1200
- * OptimizeCSSAssets plugin options.
1201
- * Defaults to true when `extractCSS` is enabled.
1202
- * @default false
1203
- *
1204
- * @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
1205
- */
1206
- optimizeCSS: false | BasePluginOptions0 & DefinedDefaultMinimizerAndOptions0<any>,
1207
-
1208
- /** Configure [webpack optimization](https://webpack.js.org/configuration/optimization/). */
1209
- optimization: false | Configuration['optimization'],
1210
-
1211
- /** Customize PostCSS Loader. Same options as https://github.com/webpack-contrib/postcss-loader#options */
1212
- postcss: {
1213
- execute: any,
1214
-
1215
- postcssOptions: {
1216
- /** @default false */
1217
- config: boolean,
1218
-
1219
- plugins: {
1220
- [key: string]: any
1221
- },
1222
- },
1223
-
1224
- sourceMap: any,
1225
-
1226
- implementation: any,
1227
-
1228
- /** @default "" */
1229
- order: string,
1230
- },
1331
+ /**
1332
+ * Hard-replaces `typeof process`, `typeof window` and `typeof document` to tree-shake bundle.
1333
+ *
1334
+ * @default false
1335
+ */
1336
+ aggressiveCodeRemoval: boolean,
1337
+
1338
+ /**
1339
+ * OptimizeCSSAssets plugin options.
1340
+ *
1341
+ * Defaults to true when `extractCSS` is enabled.
1342
+ *
1343
+ * @default false
1344
+ *
1345
+ * @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
1346
+ */
1347
+ optimizeCSS: false | BasePluginOptions0 & DefinedDefaultMinimizerAndOptions0<any>,
1348
+
1349
+ /**
1350
+ * Configure [webpack optimization](https://webpack.js.org/configuration/optimization/).
1351
+ *
1352
+ */
1353
+ optimization: false | Configuration['optimization'],
1354
+
1355
+ /**
1356
+ * Customize PostCSS Loader. Same options as https://github.com/webpack-contrib/postcss-loader#options
1357
+ *
1358
+ */
1359
+ postcss: {
1360
+ execute: any,
1231
1361
 
1232
- /** See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options. */
1233
- devMiddleware: Options<IncomingMessage, ServerResponse>,
1362
+ postcssOptions: {
1363
+ config: any,
1234
1364
 
1235
- /** See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options. */
1236
- hotMiddleware: MiddlewareOptions & { client?: ClientOptions },
1365
+ plugins: {
1366
+ [key: string]: any
1367
+ },
1368
+ },
1369
+
1370
+ sourceMap: any,
1237
1371
 
1238
- /**
1239
- * Set to `false` to disable the overlay provided by [FriendlyErrorsWebpackPlugin](https://www.npmjs.com/package/@d2js/friendly-errors-webpack-plugin).
1240
- * @default true
1241
- */
1242
- friendlyErrors: boolean,
1372
+ implementation: any,
1243
1373
 
1244
- /** Filters to hide build warnings. */
1245
- warningIgnoreFilters: Array<(warn: WebpackError) => boolean>,
1374
+ /** @default "" */
1375
+ order: string,
1246
1376
  },
1377
+
1378
+ /**
1379
+ * See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options.
1380
+ *
1381
+ */
1382
+ devMiddleware: Options<IncomingMessage, ServerResponse>,
1383
+
1384
+ /**
1385
+ * See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options.
1386
+ *
1387
+ */
1388
+ hotMiddleware: MiddlewareOptions & { client?: ClientOptions },
1389
+
1390
+ /**
1391
+ * Set to `false` to disable the overlay provided by [FriendlyErrorsWebpackPlugin](https://www.npmjs.com/package/@d2js/friendly-errors-webpack-plugin).
1392
+ *
1393
+ * @default true
1394
+ */
1395
+ friendlyErrors: boolean,
1396
+
1397
+ /**
1398
+ * Filters to hide build warnings.
1399
+ *
1400
+ */
1401
+ warningIgnoreFilters: Array<(warn: WebpackError) => boolean>,
1402
+ },
1247
1403
  }