@modern-js/module-tools-docs 2.0.0-beta.4

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.
Files changed (163) hide show
  1. package/LICENSE +144 -0
  2. package/docs/.island/config.ts +245 -0
  3. package/docs/.island/dist/404.html +41 -0
  4. package/docs/.island/dist/assets/before-getting-started.1b82b538.js +87 -0
  5. package/docs/.island/dist/assets/before-getting-started.582a31cc.js +87 -0
  6. package/docs/.island/dist/assets/build-config.72eb0918.js +804 -0
  7. package/docs/.island/dist/assets/build-config.d8bb1658.js +809 -0
  8. package/docs/.island/dist/assets/build-preset.96805d7d.js +256 -0
  9. package/docs/.island/dist/assets/build-preset.c20dcd40.js +256 -0
  10. package/docs/.island/dist/assets/build-your-ui.7f349247.js +2 -0
  11. package/docs/.island/dist/assets/build-your-ui.a8361604.js +2 -0
  12. package/docs/.island/dist/assets/command-preview.2d45fc82.js +264 -0
  13. package/docs/.island/dist/assets/command-preview.dc51b953.js +264 -0
  14. package/docs/.island/dist/assets/components.esm.03560353.js +9 -0
  15. package/docs/.island/dist/assets/design-system.86694ff5.js +1254 -0
  16. package/docs/.island/dist/assets/design-system.c4745cce.js +639 -0
  17. package/docs/.island/dist/assets/dev.1d326a37.js +37 -0
  18. package/docs/.island/dist/assets/dev.1fd06000.js +37 -0
  19. package/docs/.island/dist/assets/down.f35427d3.svg +1 -0
  20. package/docs/.island/dist/assets/extension.12299fd6.js +2 -0
  21. package/docs/.island/dist/assets/extension.96dc63a4.js +2 -0
  22. package/docs/.island/dist/assets/getting-started.40e9218d.js +117 -0
  23. package/docs/.island/dist/assets/getting-started.b1ed3f10.js +114 -0
  24. package/docs/.island/dist/assets/github.3bf8ccee.svg +1 -0
  25. package/docs/.island/dist/assets/index.2b2347ea.js +33 -0
  26. package/docs/.island/dist/assets/index.6cef6f5f.js +4 -0
  27. package/docs/.island/dist/assets/index.cb118238.js +36 -0
  28. package/docs/.island/dist/assets/index.ccb6ce27.js +4 -0
  29. package/docs/.island/dist/assets/island_inject.11a12ecc.js +1 -0
  30. package/docs/.island/dist/assets/island_inject.b13deaee.js +1 -0
  31. package/docs/.island/dist/assets/loading.8c9bb911.svg +1 -0
  32. package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +100 -0
  33. package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +100 -0
  34. package/docs/.island/dist/assets/moon.6b705924.svg +3 -0
  35. package/docs/.island/dist/assets/plugin.895932d8.js +42 -0
  36. package/docs/.island/dist/assets/plugin.d2fbc531.js +42 -0
  37. package/docs/.island/dist/assets/publish-your-project.21b8309f.js +164 -0
  38. package/docs/.island/dist/assets/publish-your-project.8d398b17.js +166 -0
  39. package/docs/.island/dist/assets/right.89674cd7.svg +1 -0
  40. package/docs/.island/dist/assets/search.0aea6901.svg +1 -0
  41. package/docs/.island/dist/assets/search.1c85d17c.js +3 -0
  42. package/docs/.island/dist/assets/search.484eca11.js +222 -0
  43. package/docs/.island/dist/assets/search.54fca8d0.js +3 -0
  44. package/docs/.island/dist/assets/style.09015a4b.css +1 -0
  45. package/docs/.island/dist/assets/style.2e5f7bc2.css +1970 -0
  46. package/docs/.island/dist/assets/sun.841dac10.svg +11 -0
  47. package/docs/.island/dist/assets/test-your-project.18bd4582.js +190 -0
  48. package/docs/.island/dist/assets/test-your-project.f53bebf7.js +190 -0
  49. package/docs/.island/dist/assets/test.0da1f99f.js +67 -0
  50. package/docs/.island/dist/assets/test.0e81f002.js +66 -0
  51. package/docs/.island/dist/assets/translator.b1077c44.svg +1 -0
  52. package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +60 -0
  53. package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +60 -0
  54. package/docs/.island/dist/assets/using-storybook.57ea6b77.js +260 -0
  55. package/docs/.island/dist/assets/using-storybook.a2212f2e.js +260 -0
  56. package/docs/.island/dist/assets/welcome.0449a9c8.js +13 -0
  57. package/docs/.island/dist/assets/welcome.a8448931.js +13 -0
  58. package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +26 -0
  59. package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +26 -0
  60. package/docs/.island/dist/chunk-COLCRJ2V.js +1 -0
  61. package/docs/.island/dist/chunk-K5FMOYDC.js +10 -0
  62. package/docs/.island/dist/chunk-WE42KMYS.js +26 -0
  63. package/docs/.island/dist/client-entry.js +3 -0
  64. package/docs/.island/dist/en/api/build-config.html +344 -0
  65. package/docs/.island/dist/en/api/build-preset.html +82 -0
  66. package/docs/.island/dist/en/api/design-system.html +155 -0
  67. package/docs/.island/dist/en/api/dev.html +45 -0
  68. package/docs/.island/dist/en/api/index.html +41 -0
  69. package/docs/.island/dist/en/api/plugin.html +48 -0
  70. package/docs/.island/dist/en/api/test.html +58 -0
  71. package/docs/.island/dist/en/guide/before-getting-started.html +127 -0
  72. package/docs/.island/dist/en/guide/build-your-ui.html +41 -0
  73. package/docs/.island/dist/en/guide/command-preview.html +100 -0
  74. package/docs/.island/dist/en/guide/extension.html +41 -0
  75. package/docs/.island/dist/en/guide/getting-started.html +76 -0
  76. package/docs/.island/dist/en/guide/modify-output-product.html +140 -0
  77. package/docs/.island/dist/en/guide/publish-your-project.html +91 -0
  78. package/docs/.island/dist/en/guide/test-your-project.html +72 -0
  79. package/docs/.island/dist/en/guide/use-micro-generator.html +65 -0
  80. package/docs/.island/dist/en/guide/using-storybook.html +113 -0
  81. package/docs/.island/dist/en/guide/welcome.html +53 -0
  82. package/docs/.island/dist/en/guide/why-module-engineering-solution.html +49 -0
  83. package/docs/.island/dist/en/index.html +42 -0
  84. package/docs/.island/dist/react-dom.js +1 -0
  85. package/docs/.island/dist/react-dom_client.js +1 -0
  86. package/docs/.island/dist/react.js +1 -0
  87. package/docs/.island/dist/react_jsx-runtime.js +10 -0
  88. package/docs/.island/dist/ssr-manifest.json +57 -0
  89. package/docs/.island/dist/test-result.png +0 -0
  90. package/docs/.island/dist/why-module-solution.png +0 -0
  91. package/docs/.island/dist/zh/api/build-config.html +347 -0
  92. package/docs/.island/dist/zh/api/build-preset.html +82 -0
  93. package/docs/.island/dist/zh/api/design-system.html +149 -0
  94. package/docs/.island/dist/zh/api/dev.html +46 -0
  95. package/docs/.island/dist/zh/api/index.html +41 -0
  96. package/docs/.island/dist/zh/api/plugin.html +48 -0
  97. package/docs/.island/dist/zh/api/test.html +59 -0
  98. package/docs/.island/dist/zh/guide/before-getting-started.html +127 -0
  99. package/docs/.island/dist/zh/guide/build-your-ui.html +41 -0
  100. package/docs/.island/dist/zh/guide/command-preview.html +100 -0
  101. package/docs/.island/dist/zh/guide/extension.html +41 -0
  102. package/docs/.island/dist/zh/guide/getting-started.html +79 -0
  103. package/docs/.island/dist/zh/guide/modify-output-product.html +140 -0
  104. package/docs/.island/dist/zh/guide/publish-your-project.html +92 -0
  105. package/docs/.island/dist/zh/guide/test-your-project.html +72 -0
  106. package/docs/.island/dist/zh/guide/use-micro-generator.html +65 -0
  107. package/docs/.island/dist/zh/guide/using-storybook.html +114 -0
  108. package/docs/.island/dist/zh/guide/welcome.html +53 -0
  109. package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +49 -0
  110. package/docs/.island/dist/zh/index.html +42 -0
  111. package/docs/.island/index.html +39 -0
  112. package/docs/.island/styles/index.css +10 -0
  113. package/docs/en/api/build-config.md +501 -0
  114. package/docs/en/api/build-preset.md +214 -0
  115. package/docs/en/api/design-system.md +524 -0
  116. package/docs/en/api/dev.md +32 -0
  117. package/docs/en/api/index.md +3 -0
  118. package/docs/en/api/plugin.md +34 -0
  119. package/docs/en/api/test.md +48 -0
  120. package/docs/en/guide/advance/asset.mdx +132 -0
  121. package/docs/en/guide/advance/build-umd.mdx +241 -0
  122. package/docs/en/guide/advance/copy.md +235 -0
  123. package/docs/en/guide/advance/external-dependency.mdx +125 -0
  124. package/docs/en/guide/advance/in-depth-about-build.md +266 -0
  125. package/docs/en/guide/advance/in-depth-about-dev-command.md +22 -0
  126. package/docs/en/guide/basic/before-getting-started.md +187 -0
  127. package/docs/en/guide/basic/command-preview.md +204 -0
  128. package/docs/en/guide/basic/modify-output-product.md +145 -0
  129. package/docs/en/guide/basic/publish-your-project.md +115 -0
  130. package/docs/en/guide/basic/test-your-project.mdx +158 -0
  131. package/docs/en/guide/basic/use-micro-generator.md +35 -0
  132. package/docs/en/guide/basic/using-storybook.mdx +187 -0
  133. package/docs/en/guide/intro/getting-started.md +78 -0
  134. package/docs/en/guide/intro/welcome.md +14 -0
  135. package/docs/en/guide/intro/why-module-engineering-solution.md +17 -0
  136. package/docs/en/index.md +35 -0
  137. package/docs/public/test-result.png +0 -0
  138. package/docs/public/why-module-solution.png +0 -0
  139. package/docs/zh/api/build-config.md +570 -0
  140. package/docs/zh/api/build-preset.md +220 -0
  141. package/docs/zh/api/design-system.md +1147 -0
  142. package/docs/zh/api/dev.md +33 -0
  143. package/docs/zh/api/index.md +3 -0
  144. package/docs/zh/api/plugins.md +108 -0
  145. package/docs/zh/api/testing.md +52 -0
  146. package/docs/zh/guide/advance/asset.mdx +132 -0
  147. package/docs/zh/guide/advance/build-umd.mdx +232 -0
  148. package/docs/zh/guide/advance/copy.md +235 -0
  149. package/docs/zh/guide/advance/external-dependency.mdx +125 -0
  150. package/docs/zh/guide/advance/in-depth-about-build.md +267 -0
  151. package/docs/zh/guide/advance/in-depth-about-dev-command.md +26 -0
  152. package/docs/zh/guide/basic/before-getting-started.md +187 -0
  153. package/docs/zh/guide/basic/command-preview.md +204 -0
  154. package/docs/zh/guide/basic/modify-output-product.md +144 -0
  155. package/docs/zh/guide/basic/publish-your-project.md +112 -0
  156. package/docs/zh/guide/basic/test-your-project.mdx +158 -0
  157. package/docs/zh/guide/basic/use-micro-generator.md +35 -0
  158. package/docs/zh/guide/basic/using-storybook.mdx +186 -0
  159. package/docs/zh/guide/intro/getting-started.md +78 -0
  160. package/docs/zh/guide/intro/welcome.md +14 -0
  161. package/docs/zh/guide/intro/why-module-engineering-solution.md +17 -0
  162. package/docs/zh/index.md +29 -0
  163. package/package.json +19 -0
@@ -0,0 +1,501 @@
1
+ # BuildConfig
2
+ This section describes all the configuration of Module tools for building
3
+ ## alias
4
+ - type: `Record<string, string | string[]> | Function`
5
+ - default: `{'@': 'src',}`
6
+
7
+ :::tip
8
+ For TypeScript projects, you only need to configure [compilerOptions.paths](https://www.typescriptlang.org/tsconfig#paths) in `tsconfig.json`, Module tools will automatically recognize the alias in `tsconfig.json`, so there is no need to configure the `alias` field additionally.
9
+ :::
10
+
11
+ ```js
12
+ export default {
13
+ build: {
14
+ alias: {
15
+ '@common': '. /src/common',
16
+ },
17
+ },
18
+ };
19
+ ```
20
+
21
+ After the above configuration is done, if `@common/Foo.tsx` is referenced in the code, it will map to the `<root>/src/common/Foo.tsx` path.
22
+
23
+ When the value of `alias` is defined as a function, you can accept the pre-defined alias object and modify it.
24
+
25
+ ```js
26
+ export default {
27
+ build: {
28
+ alias: alias => {
29
+ alias['@common'] = '. /src/common';
30
+ },
31
+ },
32
+ };
33
+ ```
34
+
35
+ It is also possible to return a new object as the final result in the function, which will override the pre-defined alias object.
36
+
37
+ ```js
38
+ export default {
39
+ build: {
40
+ alias: alias => {
41
+ return {
42
+ '@common': '. /src/common',
43
+ };
44
+ },
45
+ },
46
+ };
47
+ ```
48
+
49
+ ## asset
50
+
51
+ ### path
52
+ Static resource output path, will be based on [outdir](/zh/api/build-config/#outdir)
53
+
54
+ - type: `string`
55
+ - default: `assets`
56
+
57
+ ### limit
58
+ Threshold for automatically inlining static resources when building, resources less than 10240 bytes will be automatically inlined into the bundle product
59
+
60
+ - type: `number`
61
+ - default: `10 * 1024`
62
+
63
+ ### publicPath
64
+ The CDN prefix given to unlinked resources when packaging
65
+ - type: `string`
66
+ - default: `undefined`
67
+ ```js
68
+ export default {
69
+ build: {
70
+ asset: {
71
+ publicPath: 'https://xxx/'
72
+ }
73
+ }
74
+ };
75
+ ```
76
+ At this point, all static resources will be prefixed with `https://xxx/`
77
+
78
+ ### svgr
79
+ Treat svg as a React component when packaging
80
+ - type: `boolean | Object`
81
+
82
+ #### include
83
+ Set the matching svg file
84
+ - type: `string | RegExp | (string | RegExp)[]`
85
+ - default: `/\.svg$/`
86
+
87
+ #### exclude
88
+ Set unmatched svg files
89
+ - type: `string | RegExp | (string | RegExp)[]`
90
+ - default: `undefined`
91
+
92
+
93
+ ## autoExternal
94
+ Automatically externalize project dependencies and peerDependencies and not package them into the final bundle
95
+ - type: `boolean | Object`
96
+ - default: `true`
97
+
98
+ ### dependencies
99
+ Whether or not the dep dependencies of the external project are needed
100
+ - type: `boolean`
101
+ - default: `true`
102
+
103
+ ### peerDependencies
104
+ Whether to require peerDep dependencies for external projects
105
+ - type: `boolean`
106
+ - default: `true`
107
+
108
+ ## buildType
109
+ The build type, `bundle` will package your code, `bundleless` will only do the code conversion
110
+ - type: `'bundle' | 'bundleless'`
111
+ - default: `bundle`
112
+
113
+ ## copy
114
+ Copies the specified file or directory into the build output directory
115
+ - type: `Array`
116
+ - default: `[]`
117
+ ``js
118
+
119
+ export default {
120
+ build: {
121
+ copy: [{ from: '. /src/assets', to: '' }],
122
+ },
123
+ };
124
+ ```
125
+ Reference for array settings: [copy-webpack-plugin patterns](https://github.com/webpack-contrib/copy-webpack-plugin#patterns)
126
+
127
+ ## define
128
+ Define global variables that will be injected into the code
129
+ - type: `Record<string, string>`
130
+ - default: `{}`
131
+
132
+ Since the `define` function is implemented by global text replacement, you need to ensure that the global variable values are strings. A safer approach is to convert the value of each global variable to a string, using `JSON.stringify`, as follows.
133
+ ```js
134
+ export default {
135
+ build: {
136
+ define: {
137
+ 'VERSION': JSON.stringify('1.0'),
138
+
139
+ },
140
+ },
141
+ };
142
+ ```
143
+
144
+ :::tip
145
+ To prevent excessive global replacement substitution, it is recommended that the following two principles be followed when using
146
+ - Use upper case for global constants
147
+ - Customize the prefix and suffix of global constants to ensure uniqueness
148
+ :::
149
+
150
+ ## dts
151
+ The dts file generates the relevant configuration, by default it generates
152
+
153
+ - type: `false | Object`
154
+ - default: `{}`
155
+
156
+ ### tsconfigPath
157
+ Path to the tsconfig file
158
+ - type: `string`
159
+ - default: `. /tsconfig.json`
160
+
161
+ ### distPath
162
+ The output path of the dts file, based on [outdir]('/zh/api/build-config/#outdir')
163
+ - type: `string`
164
+ - default: `. /types`
165
+
166
+ ### only
167
+ Generate only dts files, not js files
168
+ - type: `boolean`
169
+ - default: `false`
170
+
171
+ ## externals
172
+ Configure external dependencies that will not be packaged into the final bundle
173
+ - type: `(string | RegExp)[]`
174
+ - default: `[]`
175
+ ## format
176
+ The format of the js product output, where `iife` and `umd` can only take effect when `buildType` is `bundle`
177
+ - type: `'esm' | 'cjs' | 'iife' | 'umd'`
178
+ - default: `cjs`
179
+
180
+ ## input
181
+ Specify the entry file for the build, in the form of an array that can specify the directory
182
+ - type: `string[] | Record<string, string>`
183
+ - default: `['src/index.ts']` in `bundle` mode, `['src']` in `bundleless` mode
184
+
185
+ ```js
186
+ export default {
187
+ build: {
188
+ input: ['src/index.ts', 'src/index2.ts'],
189
+ },
190
+ };
191
+ ```
192
+
193
+ ## jsx
194
+ Specify the compilation method of jsx, default support React17, automatically inject jsx runtime code
195
+ - type: `automatic | classic`
196
+ - default: `automatic`
197
+
198
+ ## minify
199
+ Use esbuild or terser to compress code, also pass [terserOptions](https://github.com/terser/terser#minify-options)
200
+ - type: `'terser' | 'esbuild' | false | Object`
201
+ - default: `false`
202
+
203
+ ```js
204
+ export default {
205
+ build: {
206
+ minify: {
207
+ compress: {
208
+ drop_console: true,
209
+ },
210
+ },
211
+ },
212
+ };
213
+ ```
214
+
215
+ ## outdir
216
+ Specifies the output directory of the build
217
+ - type: `string`
218
+ - default: `dist`
219
+
220
+ ## platform
221
+ Generates code for the node environment by default, you can also specify `browser` which will generate code for the browser environment
222
+ - type: `'browser' | 'node'`
223
+ - default: `node`
224
+
225
+ ## sourceDir
226
+ Specify the source directory of the build, default is `src`, which is used to generate the corresponding product directory based on the source directory structure when building `bundleless`.
227
+ - type: `string`
228
+ - default: `src`
229
+
230
+ ## sourceMap
231
+ Whether to generate sourceMap or not
232
+ - type: `boolean | 'inline' | 'external'`
233
+ - default: `false`
234
+
235
+ ## splitting
236
+ Whether to enable code splitting
237
+ - type: `boolean`
238
+ - default: `false`
239
+
240
+ ## style
241
+ Configure style-related configuration
242
+
243
+ ### less
244
+ less-related configuration
245
+ #### lessOptions
246
+ Refer to [less](https://less.bootcss.com/usage/#less-options) for detailed configuration
247
+ - type: `Object`
248
+ - default: `{ javascriptEnabled: true }`
249
+
250
+ #### additionalData
251
+ Add `Less` code to the beginning of the entry file.
252
+ - type: `string`
253
+ - default: `undefined`
254
+
255
+ ```js
256
+ export default {
257
+ build: {
258
+ style: {
259
+ less: {
260
+ additionalData: `@base-color: #c6538c;`,
261
+ },
262
+ }
263
+ }
264
+ }
265
+
266
+ ```
267
+ #### implementation
268
+ Configure the implementation library used by `Less`, if not specified, the built-in version used is `4.1.3`
269
+ - type: `string | Object`
270
+ - default: `undefined`
271
+
272
+ Specify the implementation library for `Less` when the `Object` type is specified
273
+ ```js
274
+ export default {
275
+ build: {
276
+ style: {
277
+ less: {
278
+ implementation: require('less'),
279
+ },
280
+ }
281
+ }
282
+ }
283
+ ```
284
+
285
+ For the `string` type, specify the path to the implementation library for `Less`
286
+ ```js
287
+ export default {
288
+ build: {
289
+ style: {
290
+ less: {
291
+ implementation: require.resolve('less'),
292
+ },
293
+ }
294
+ }
295
+ }
296
+ ```
297
+
298
+ ### sass
299
+ sass-related configuration
300
+ #### sassOptions
301
+ Refer to [node-sass](https://github.com/sass/node-sass#options) for detailed configuration
302
+ - type: `Object`
303
+ - default: `{}`
304
+ #### additionalData
305
+ Add `Sass` code to the beginning of the entry file.
306
+ - type: `string | Function`
307
+ - default: `undefined`
308
+ ```js
309
+ export default {
310
+ build: {
311
+ style: {
312
+ sass: {
313
+ additionalData: `$base-color: #c6538c;
314
+ $border-dark: rgba($base-color, 0.88);`,
315
+ },
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ #### implementation
322
+ Configure the implementation library used by `Sass`, the built-in version used is `1.5.4` if not specified
323
+ - type: `string | Object`
324
+ - default: `undefined`
325
+
326
+ Specify the implementation library for `Sass` when the `Object` type is specified
327
+ ```js
328
+ export default {
329
+ build: {
330
+ style: {
331
+ sass: {
332
+ implementation: require('sass'),
333
+ },
334
+ }
335
+ }
336
+ }
337
+ ```
338
+
339
+ For the `string` type, specify the path to the `Sass` implementation library
340
+ ```js
341
+ export default {
342
+ build: {
343
+ style: {
344
+ sass: {
345
+ implementation: require.resolve('sass'),
346
+ },
347
+ }
348
+ }
349
+ }
350
+ ```
351
+
352
+ ### postcss
353
+ - plugins
354
+ - processOptions
355
+
356
+ See [postcss](https://github.com/postcss/postcss#options) for detailed configuration
357
+ ### inject
358
+ Configure whether to insert style into js in packaged mode
359
+
360
+ - type: `boolean`
361
+ - default: `false`
362
+
363
+ ### autoModules
364
+ Enable CSS Modules automatically based on the filename.
365
+
366
+ - type: `boolean | RegExp`
367
+ - default: `true `
368
+
369
+ `true` : Enables CSS Modules for style files ending with `.module.css` `.module.less` `.module.scss` `.module.sass` filenames
370
+
371
+ `false` : Disable CSS Modules.
372
+
373
+ `RegExp` : Enables CSS Modules for all files that match the regular condition.
374
+
375
+ ### modules
376
+ CSS Modules configuration
377
+
378
+ - type: `Object`
379
+ - default: `{}`
380
+
381
+ A common configuration is ``localsConvention``, which changes the class name generation rules for css modules
382
+ ```js
383
+ export default {
384
+ build: {
385
+ style: {
386
+ modules: {
387
+ localsConvention: 'camelCaseOnly',
388
+ },
389
+ }
390
+ }
391
+ }
392
+ ```
393
+ For the following styles
394
+ ```css
395
+ .box-title {
396
+ color: red;
397
+ }
398
+ ```
399
+ You can use ``styles.boxTitle`` to access
400
+
401
+
402
+ For detailed configuration see [postcss-modules](https://github.com/madyankin/postcss-modules#usage)
403
+
404
+ ### tailwind
405
+ tailwindcss related configuration
406
+
407
+ - type: `Object | Function`
408
+ - default: `see configuration details below`
409
+
410
+ <details>
411
+ <summary>TailwindCSS configuration details</summary>
412
+
413
+ ```js
414
+ const tailwind = {
415
+ purge: {
416
+ enabled: options.env === 'production',
417
+ content: [
418
+ '. /config/html/**/*.html',
419
+ '. /config/html/**/*.ejs',
420
+ '. /config/html/**/*.hbs',
421
+ '. /src/**/*',
422
+ ],
423
+ layers: ['utilities'],
424
+ },
425
+ // https://tailwindcss.com/docs/upcoming-changes
426
+ future: {
427
+ removeDeprecatedGapUtilities: false,
428
+ purgeLayersByDefault: true,
429
+ defaultLineHeights: false,
430
+ standardFontWeights: false,
431
+ },
432
+ }
433
+ ```
434
+
435
+ When the value is of type `Object`, it is merged with the default configuration via `Object.assign`.
436
+
437
+ When the value is of type `Function`, the object returned by the function is merged with the default configuration via `Object.assign`.
438
+
439
+ The `theme` property is not allowed, otherwise the build will fail, using [`designSystem`](/zh/api/design-system) as the `Tailwind CSS Theme` configuration.
440
+
441
+ The rest of the usage is the same as Tailwind CSS: [Quick Portal](https://tailwindcss.com/docs/configuration).
442
+
443
+
444
+ ## target
445
+ Specify the target environment for the build
446
+ - type: `'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext'`
447
+ - default: `'es2015'`
448
+
449
+
450
+ ## umdGlobals
451
+ Specify global variables for external import of umd products
452
+ - type: `Record<string, string>`
453
+ - default: `{}`
454
+
455
+ ```js
456
+ export default {
457
+ build: {
458
+ umdGlobals: {
459
+ react: 'React',
460
+ 'react-dom': 'ReactDOM',
461
+ },
462
+ }
463
+ }
464
+ ```
465
+ At this point, `react` and `react-dom` will be seen as global variables imported externally and will not be packed into the umd product, but will be accessible by way of `global.React` and `global.ReactDOM`
466
+
467
+ ## umdModuleName
468
+ Specifies the module name of the umd product
469
+
470
+ - type: `string` | `Function`
471
+ - default: `name => name`
472
+
473
+ ``js
474
+ export default {
475
+ build: {
476
+ format: 'umd',
477
+ umdModuleName: 'myLib',
478
+ }
479
+ }
480
+ ```
481
+ At this point the umd product will go to mount on `global.myLib`
482
+ :::tip
483
+ - The module name of the umd product must not conflict with the global variable name.
484
+ - Module names should not contain special characters like `-`, `@`, `/`, etc.
485
+ :::
486
+
487
+ Also the function form can take one parameter, which is the output path of the current package file
488
+ ```js
489
+ export default {
490
+ build: {
491
+ format: 'umd',
492
+ umdModuleName: (path) => {
493
+ if (path.includes('index')) {
494
+ return 'myLib';
495
+ } else {
496
+ return 'myLib2';
497
+ }
498
+ },
499
+ }
500
+ }
501
+ ```
@@ -0,0 +1,214 @@
1
+ # BuildPreset
2
+ A build preset string or preset function. Provides out-of-the-box build configuration
3
+
4
+ - type: `string | Function`
5
+ - default: `undefined`
6
+
7
+
8
+ ## string
9
+
10
+ The string form allows you to use the built-in presets directly
11
+
12
+ ```js
13
+ export default {
14
+ buildPreset: 'npm-library',
15
+ };
16
+ ```
17
+
18
+
19
+ ### ``npm-library'`
20
+ Library generic schema used under class [NPM](https://www.npmjs.com/) package manager, contains `esm` and `cjs` Bundle products, and includes a type file.
21
+
22
+ :::info
23
+ About the class [NPM](https://www.npmjs.com/) Package Manager
24
+ * [npm](https://www.npmjs.com)
25
+ * [yarn](https://yarnpkg.com/)
26
+ * [pnpm](https://pnpm.io/)
27
+ :::
28
+
29
+ ```json title="package.json"
30
+ {
31
+ "main": ". /dist/lib/index.js",
32
+ "module": ". /dist/es/index.js",
33
+ "types": ". /dist/types/index.d.ts",
34
+ }
35
+ ```
36
+ The build configuration corresponding to the preset string.
37
+ ```js
38
+ export const buildConfig = [
39
+ {
40
+ format: 'cjs',
41
+ target: 'es6',
42
+ buildType: 'bundle',
43
+ outdir: '. /lib',
44
+ },
45
+ {
46
+ format: 'esm',
47
+ target: 'es6',
48
+ buildType: 'bundle',
49
+ outdir: '. /es',
50
+ },
51
+ {
52
+ buildType: 'bundle',
53
+ outdir: '. /types',
54
+ dts: {
55
+ only: true,
56
+ },
57
+ },
58
+ ];
59
+ ```
60
+
61
+ ### ``npm-library-with-umd'``
62
+ Used under class [NPM](https://www.npmjs.com/) package manager, and Library supports a similar pattern to [unpkg](https://unpkg.com/). Additional ``umd`` products are provided on top of the pre-defined ``npm-library'`.
63
+
64
+ ```json title="package.json"
65
+ {
66
+ "main": ". /dist/lib/index.js",
67
+ "module": ". /dist/es/index.js",
68
+ "types": ". /dist/types/index.d.ts",
69
+ "unpkg": ". /dist/umd/index.js",
70
+ };
71
+ ```
72
+ The build configuration corresponding to the preset string.
73
+ ```js
74
+ export const buildConfig = [
75
+ {
76
+ format: 'cjs',
77
+ target: 'es6',
78
+ buildType: 'bundle',
79
+ outdir: '. /lib',
80
+ },
81
+ {
82
+ format: 'esm',
83
+ target: 'es6',
84
+ buildType: 'bundle',
85
+ outdir: '. /es',
86
+ },
87
+ {
88
+ format: 'umd',
89
+ target: 'es6',
90
+ buildType: 'bundle',
91
+ outdir: '. /umd',
92
+ },
93
+ {
94
+ buildType: 'bundle',
95
+ outdir: '. /types',
96
+ dts: {
97
+ only: true,
98
+ },
99
+ },
100
+ ];
101
+ ```
102
+
103
+ ### `'npm-component'`
104
+ A generic pattern for components (libraries) used under the class [NPM](https://www.npmjs.com/) package manager. Contains both `esm` and `cjs` Bundleless products (for easy *[Tree shaking](https://developer.mozilla.org/zh-CN/docs/Glossary/Tree_shaking)* optimization), as well as including a copy of the type file.
105
+
106
+ For style files included in the source code, the products provide the compiled product of the style and the source file of the style.
107
+
108
+ ```json title="package.json"
109
+ {
110
+ "main": ". /dist/lib/index.js", // bundleless type
111
+ "module": ". /dist/es/index.js", // bundleless type
112
+ "types": ". /dist/types/index.d.ts",
113
+ };
114
+ ```
115
+ The pre-defined strings correspond to the build configuration.
116
+
117
+ ``` js
118
+ export const buildConfig = [
119
+ {
120
+ format: 'cjs',
121
+ target: 'es6',
122
+ buildType: 'bundleless',
123
+ outdir: '. /lib',
124
+ },
125
+ {
126
+ format: 'esm',
127
+ target: 'es6',
128
+ buildType: 'bundleless',
129
+ outdir: '. /es',
130
+ },
131
+ {
132
+ buildType: 'bundleless',
133
+ outdir: '. /types',
134
+ dts: {
135
+ only: true,
136
+ },
137
+ },
138
+ ];
139
+ ```
140
+
141
+ ### `'npm-component-with-umd'`
142
+
143
+ Component (library) used under class [NPM](https://www.npmjs.com/) package manager, with support for class [unpkg](https://unpkg.com/) schema. Additional ``umd`` products are provided on top of the pre-defined ``npm-component'`.
144
+ ```json title="package.json"
145
+ {
146
+ "main": ". /dist/lib/index.js", // bundleless type
147
+ "module": ". /dist/es/index.js", // bundleless type
148
+ "types": ". /dist/types/index.d.ts",
149
+ "unpkg": ". /dist/umd/index.js",
150
+ };
151
+ ```
152
+ ```js
153
+ export const buildConfig = [
154
+ {
155
+ format: 'cjs',
156
+ target: 'es6',
157
+ buildType: 'bundleless',
158
+ outdir: '. /lib',
159
+ },
160
+ {
161
+ format: 'esm',
162
+ target: 'es6',
163
+ buildType: 'bundleless',
164
+ outdir: '. /es',
165
+ },
166
+ {
167
+ format: 'umd',
168
+ target: 'es6',
169
+ buildType: 'bundle',
170
+ outdir: '. /umd',
171
+ },
172
+ {
173
+ buildType: 'bundleless',
174
+ outdir: '. /types',
175
+ dts: {
176
+ only: true,
177
+ },
178
+ },
179
+ ];
180
+ ```
181
+
182
+ ### About the ECMAScript versions supported by the preset and `{es5.... .esnext}`
183
+
184
+
185
+ When you want to use a `buildPreset` preset that supports other ECMAScript versions, you can directly add the supported versions to the `'npm-library'`, `'npm-library-with-umd'`, `'npm-component'`, `'npm-component-with-umd'` presets.
186
+
187
+ For example, if you want the ``npm-library'` preset to support ``es2017``, you can configure it as follows.
188
+
189
+ ```js
190
+ export default {
191
+ buildPreset: 'npm-library-es2017',
192
+ };
193
+ ```
194
+
195
+ ## Function
196
+
197
+ The way the function is configured, you can get the preset value with the `preset` parameter and then modify the build configuration inside to customize your build configuration.
198
+ The following is an example of how a function can be configured to compress a build product.
199
+
200
+ ```js
201
+ export default {
202
+ buildPreset({ preset }) {
203
+ const { NPM_LIBRARY } = preset;
204
+ return NPM_LIBRARY.map(config => {
205
+ config.minify = {
206
+ compress: {
207
+ drop_console: true,
208
+ },
209
+ };
210
+ return config;
211
+ });
212
+ },
213
+ }
214
+ ```