@dtwo/schema 3.0.0-rc.13
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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.d.ts +1937 -0
- package/dist/index.mjs +567 -0
- package/package.json +41 -0
- package/schema/config.d.ts +1247 -0
- package/schema/config.defaults.json +335 -0
- package/schema/config.md +1221 -0
- package/schema/config.schema.json +2587 -0
|
@@ -0,0 +1,1247 @@
|
|
|
1
|
+
import type { ComponentsOptions } from '../src/types/components'
|
|
2
|
+
import type { ImportsOptions } from '../src/types/imports'
|
|
3
|
+
import type { CompilerOptions } from '@kdujs/compiler-core'
|
|
4
|
+
import type { DtwoAppConfig, RuntimeConfig, AppConfig, WiteConfig } from '../src/types/config'
|
|
5
|
+
import type { DtwoPlugin, Dtwo } from '../src/types/dtwo'
|
|
6
|
+
import type { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
|
7
|
+
import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer'
|
|
8
|
+
import type { DtwoModule } from '../src/types/module'
|
|
9
|
+
import type { DtwoHooks } from '../src/types/hooks'
|
|
10
|
+
import type { HoleConfig, HoleEventHandler, HoleDevEventHandler } from 'holepack'
|
|
11
|
+
import type { readPackageJSON } from 'pkg-types'
|
|
12
|
+
import type { PluginOptions } from 'mini-css-extract-plugin'
|
|
13
|
+
import type { BasePluginOptions, DefinedDefaultMinimizerAndOptions } from 'terser-webpack-plugin'
|
|
14
|
+
import type { BasePluginOptions as BasePluginOptions0, DefinedDefaultMinimizerAndOptions as DefinedDefaultMinimizerAndOptions0 } from 'css-minimizer-webpack-plugin'
|
|
15
|
+
import type { Configuration, WebpackError } from 'webpack'
|
|
16
|
+
import type { Options } from 'webpack-dev-middleware'
|
|
17
|
+
import type { IncomingMessage, ServerResponse } from 'http'
|
|
18
|
+
import type { MiddlewareOptions, ClientOptions } from 'webpack-hot-middleware'
|
|
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.
|
|
23
|
+
*
|
|
24
|
+
* @default {{ dirs: [`~/components`] }}
|
|
25
|
+
*/
|
|
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
|
+
},
|
|
46
|
+
|
|
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
|
+
},
|
|
152
|
+
|
|
153
|
+
/**
|
|
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.
|
|
157
|
+
*
|
|
158
|
+
* @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
|
+
* ]
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
plugins: (DtwoPlugin | string)[],
|
|
171
|
+
|
|
172
|
+
/**
|
|
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.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```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
|
+
* ]
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
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
|
+
},
|
|
246
|
+
|
|
247
|
+
/**
|
|
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.
|
|
251
|
+
*/
|
|
252
|
+
extends: string|string[],
|
|
253
|
+
|
|
254
|
+
/**
|
|
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
|
|
259
|
+
*/
|
|
260
|
+
theme: string,
|
|
261
|
+
|
|
262
|
+
/**
|
|
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>"
|
|
267
|
+
*/
|
|
268
|
+
rootDir: string,
|
|
269
|
+
|
|
270
|
+
/**
|
|
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>"
|
|
275
|
+
*/
|
|
276
|
+
workspaceDir: string,
|
|
277
|
+
|
|
278
|
+
/**
|
|
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>"
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```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/
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
srcDir: string,
|
|
308
|
+
|
|
309
|
+
/**
|
|
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"
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```js
|
|
323
|
+
* export default {
|
|
324
|
+
* buildDir: 'dtwo-build'
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
buildDir: string,
|
|
329
|
+
|
|
330
|
+
/**
|
|
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"]
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```js
|
|
338
|
+
* export default {
|
|
339
|
+
* modulesDir: ['../../node_modules']
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
modulesDir: Array<string>,
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Whether Dtwo is running in development mode.
|
|
347
|
+
* Normally, you should not need to set this.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
dev: boolean,
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Whether your app is being unit tested.
|
|
354
|
+
* @default false
|
|
355
|
+
*/
|
|
356
|
+
test: boolean,
|
|
357
|
+
|
|
358
|
+
/**
|
|
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
|
|
362
|
+
*/
|
|
363
|
+
debug: boolean,
|
|
364
|
+
|
|
365
|
+
/**
|
|
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
|
|
368
|
+
*/
|
|
369
|
+
ssr: boolean,
|
|
370
|
+
|
|
371
|
+
/**
|
|
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.
|
|
375
|
+
*
|
|
376
|
+
* @note Modules are executed sequentially so the order is important.
|
|
377
|
+
*
|
|
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
|
+
* ```
|
|
391
|
+
*/
|
|
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
|
+
},
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The extensions that should be resolved by the Dtwo resolver.
|
|
445
|
+
* @default [".js",".jsx",".mjs",".ts",".tsx",".kdu"]
|
|
446
|
+
*/
|
|
447
|
+
extensions: Array<string>,
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
|
451
|
+
*
|
|
452
|
+
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
|
|
453
|
+
* your alias by prefixing it with `~`.
|
|
454
|
+
*
|
|
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`.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```js
|
|
461
|
+
* 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))
|
|
466
|
+
* }
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
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
|
+
*/
|
|
490
|
+
alias: Record<string, string>,
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Pass options directly to `node-ignore` (which is used by Dtwo to ignore files).
|
|
494
|
+
*
|
|
495
|
+
* @see [node-ignore](https://github.com/kaelzhang/node-ignore)
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```js
|
|
499
|
+
* ignoreOptions: {
|
|
500
|
+
* ignorecase: false
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
ignoreOptions: any,
|
|
505
|
+
|
|
506
|
+
/**
|
|
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 "-"
|
|
509
|
+
*/
|
|
510
|
+
ignorePrefix: string,
|
|
511
|
+
|
|
512
|
+
/**
|
|
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","**\/-*.*"]
|
|
515
|
+
*/
|
|
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
|
+
},
|
|
543
|
+
|
|
544
|
+
/**
|
|
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).
|
|
548
|
+
*
|
|
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
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
hooks: DtwoHooks,
|
|
569
|
+
|
|
570
|
+
/**
|
|
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.
|
|
576
|
+
*
|
|
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
|
+
* ```
|
|
588
|
+
*/
|
|
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
|
+
},
|
|
635
|
+
|
|
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
|
+
},
|
|
710
|
+
|
|
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
|
+
},
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* @default 3
|
|
773
|
+
*
|
|
774
|
+
* @private
|
|
775
|
+
*/
|
|
776
|
+
_majorVersion: number,
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* @default false
|
|
780
|
+
*
|
|
781
|
+
* @private
|
|
782
|
+
*/
|
|
783
|
+
_legacyGenerate: boolean,
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @default false
|
|
787
|
+
*
|
|
788
|
+
* @private
|
|
789
|
+
*/
|
|
790
|
+
_start: boolean,
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* @default false
|
|
794
|
+
*
|
|
795
|
+
* @private
|
|
796
|
+
*/
|
|
797
|
+
_build: boolean,
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @default false
|
|
801
|
+
*
|
|
802
|
+
* @private
|
|
803
|
+
*/
|
|
804
|
+
_generate: boolean,
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* @default false
|
|
808
|
+
*
|
|
809
|
+
* @private
|
|
810
|
+
*/
|
|
811
|
+
_prepare: boolean,
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* @default false
|
|
815
|
+
*
|
|
816
|
+
* @private
|
|
817
|
+
*/
|
|
818
|
+
_cli: boolean,
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
*
|
|
822
|
+
* @private
|
|
823
|
+
*/
|
|
824
|
+
_requiredModules: any,
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
*
|
|
828
|
+
* @private
|
|
829
|
+
*/
|
|
830
|
+
_dtwoConfigFile: any,
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
*
|
|
834
|
+
* @private
|
|
835
|
+
*/
|
|
836
|
+
_dtwoConfigFiles: Array<any>,
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* @default ""
|
|
840
|
+
*
|
|
841
|
+
* @private
|
|
842
|
+
*/
|
|
843
|
+
appDir: string,
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
*
|
|
847
|
+
* @private
|
|
848
|
+
*/
|
|
849
|
+
_installedModules: Array<any>,
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
*
|
|
853
|
+
* @private
|
|
854
|
+
*/
|
|
855
|
+
_modules: Array<any>,
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Configuration for Hole.
|
|
859
|
+
*
|
|
860
|
+
* @see https://holepack.web.app/config/
|
|
861
|
+
*/
|
|
862
|
+
hole: HoleConfig,
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Global route options applied to matching server routes.
|
|
866
|
+
*
|
|
867
|
+
* @experimental This is an experimental feature and API may change in the future.
|
|
868
|
+
*
|
|
869
|
+
* @see https://holepack.web.app/config/#routes
|
|
870
|
+
*/
|
|
871
|
+
routeRules: HoleConfig['routeRules'],
|
|
872
|
+
|
|
873
|
+
/**
|
|
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.
|
|
876
|
+
*
|
|
877
|
+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Dtwo.
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```js
|
|
881
|
+
* serverHandlers: [
|
|
882
|
+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
|
883
|
+
* ]
|
|
884
|
+
* ```
|
|
885
|
+
*/
|
|
886
|
+
serverHandlers: HoleEventHandler[],
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Hole development-only server handlers.
|
|
890
|
+
*
|
|
891
|
+
* @see https://holepack.web.app/guide/introduction/routing
|
|
892
|
+
*/
|
|
893
|
+
devServerHandlers: HoleDevEventHandler[],
|
|
894
|
+
|
|
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
|
+
},
|
|
908
|
+
|
|
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
|
+
},
|
|
919
|
+
|
|
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,
|
|
950
|
+
},
|
|
951
|
+
|
|
952
|
+
/**
|
|
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.
|
|
955
|
+
*/
|
|
956
|
+
wite: WiteConfig,
|
|
957
|
+
|
|
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
|
+
},
|
|
1071
|
+
|
|
1072
|
+
/** Customize the options of Dtwo's integrated webpack loaders. */
|
|
1073
|
+
loaders: {
|
|
1074
|
+
file: {
|
|
1075
|
+
/** @default false */
|
|
1076
|
+
esModule: boolean,
|
|
1077
|
+
},
|
|
1078
|
+
|
|
1079
|
+
fontUrl: {
|
|
1080
|
+
/** @default false */
|
|
1081
|
+
esModule: boolean,
|
|
1082
|
+
|
|
1083
|
+
/** @default 1000 */
|
|
1084
|
+
limit: number,
|
|
1085
|
+
},
|
|
1086
|
+
|
|
1087
|
+
imgUrl: {
|
|
1088
|
+
/** @default false */
|
|
1089
|
+
esModule: boolean,
|
|
1090
|
+
|
|
1091
|
+
/** @default 1000 */
|
|
1092
|
+
limit: number,
|
|
1093
|
+
},
|
|
1094
|
+
|
|
1095
|
+
pugPlain: any,
|
|
1096
|
+
|
|
1097
|
+
kdu: {
|
|
1098
|
+
/** @default true */
|
|
1099
|
+
productionMode: boolean,
|
|
1100
|
+
|
|
1101
|
+
transformAssetUrls: {
|
|
1102
|
+
/** @default "src" */
|
|
1103
|
+
video: string,
|
|
1104
|
+
|
|
1105
|
+
/** @default "src" */
|
|
1106
|
+
source: string,
|
|
1107
|
+
|
|
1108
|
+
/** @default "src" */
|
|
1109
|
+
object: string,
|
|
1110
|
+
|
|
1111
|
+
/** @default "src" */
|
|
1112
|
+
embed: string,
|
|
1113
|
+
},
|
|
1114
|
+
|
|
1115
|
+
compilerOptions: {
|
|
1116
|
+
[key: string]: any
|
|
1117
|
+
},
|
|
1118
|
+
},
|
|
1119
|
+
|
|
1120
|
+
css: {
|
|
1121
|
+
/** @default 0 */
|
|
1122
|
+
importLoaders: number,
|
|
1123
|
+
|
|
1124
|
+
url: {
|
|
1125
|
+
filter: () => any,
|
|
1126
|
+
},
|
|
1127
|
+
|
|
1128
|
+
/** @default false */
|
|
1129
|
+
esModule: boolean,
|
|
1130
|
+
},
|
|
1131
|
+
|
|
1132
|
+
cssModules: {
|
|
1133
|
+
/** @default 0 */
|
|
1134
|
+
importLoaders: number,
|
|
1135
|
+
|
|
1136
|
+
url: {
|
|
1137
|
+
filter: () => any,
|
|
1138
|
+
},
|
|
1139
|
+
|
|
1140
|
+
/** @default false */
|
|
1141
|
+
esModule: boolean,
|
|
1142
|
+
|
|
1143
|
+
modules: {
|
|
1144
|
+
/** @default "[local]_[hash:base64:5]" */
|
|
1145
|
+
localIdentName: string,
|
|
1146
|
+
},
|
|
1147
|
+
},
|
|
1148
|
+
|
|
1149
|
+
less: any,
|
|
1150
|
+
|
|
1151
|
+
sass: {
|
|
1152
|
+
sassOptions: {
|
|
1153
|
+
/** @default true */
|
|
1154
|
+
indentedSyntax: boolean,
|
|
1155
|
+
},
|
|
1156
|
+
},
|
|
1157
|
+
|
|
1158
|
+
scss: any,
|
|
1159
|
+
|
|
1160
|
+
stylus: any,
|
|
1161
|
+
|
|
1162
|
+
kduStyle: any,
|
|
1163
|
+
},
|
|
1164
|
+
|
|
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
|
+
},
|
|
1231
|
+
|
|
1232
|
+
/** See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options. */
|
|
1233
|
+
devMiddleware: Options<IncomingMessage, ServerResponse>,
|
|
1234
|
+
|
|
1235
|
+
/** See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options. */
|
|
1236
|
+
hotMiddleware: MiddlewareOptions & { client?: ClientOptions },
|
|
1237
|
+
|
|
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,
|
|
1243
|
+
|
|
1244
|
+
/** Filters to hide build warnings. */
|
|
1245
|
+
warningIgnoreFilters: Array<(warn: WebpackError) => boolean>,
|
|
1246
|
+
},
|
|
1247
|
+
}
|