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

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 (198) hide show
  1. package/.eslintrc.js +13 -0
  2. package/docs/en/api/config/_category_.json +4 -0
  3. package/docs/en/api/{build-config.md → config/build-config.md} +198 -105
  4. package/docs/en/api/{build-preset.md → config/build-preset.md} +65 -46
  5. package/docs/{zh/api → en/api/config}/design-system.md +130 -127
  6. package/docs/en/api/config/plugins.md +18 -0
  7. package/docs/en/api/{test.md → config/testing.md} +21 -12
  8. package/docs/en/api/index.md +3 -1
  9. package/docs/en/api/plugin-api/_category_.json +4 -0
  10. package/docs/en/api/plugin-api/plugin-hooks.md +501 -0
  11. package/docs/en/guide/advance/_category_.json +4 -0
  12. package/docs/en/guide/advance/asset.mdx +47 -30
  13. package/docs/en/guide/advance/build-umd.mdx +88 -80
  14. package/docs/en/guide/advance/copy.md +31 -28
  15. package/docs/en/guide/advance/external-dependency.mdx +27 -23
  16. package/docs/en/guide/advance/in-depth-about-build.md +56 -50
  17. package/docs/en/guide/advance/in-depth-about-dev-command.md +7 -4
  18. package/docs/en/guide/advance/theme-config.mdx +80 -0
  19. package/docs/en/guide/basic/_category_.json +4 -0
  20. package/docs/en/guide/basic/before-getting-started.md +28 -23
  21. package/docs/en/guide/basic/command-preview.md +18 -14
  22. package/docs/en/guide/basic/modify-output-product.md +27 -20
  23. package/docs/en/guide/basic/publish-your-project.md +21 -19
  24. package/docs/en/guide/basic/test-your-project.mdx +19 -16
  25. package/docs/en/guide/basic/use-micro-generator.md +10 -7
  26. package/docs/en/guide/basic/using-storybook.mdx +27 -26
  27. package/docs/en/guide/best-practices/_category_.json +4 -0
  28. package/docs/en/guide/best-practices/components.mdx +783 -0
  29. package/docs/en/guide/intro/_category_.json +4 -0
  30. package/docs/en/guide/intro/getting-started.md +9 -4
  31. package/docs/en/guide/intro/welcome.md +4 -0
  32. package/docs/en/guide/intro/why-module-engineering-solution.md +5 -1
  33. package/docs/en/index.md +3 -5
  34. package/docs/en/plugins/guide/_category_.json +4 -0
  35. package/docs/en/plugins/guide/getting-started.mdx +84 -0
  36. package/docs/en/plugins/guide/plugin-object.mdx +85 -0
  37. package/docs/en/plugins/guide/setup-function.mdx +117 -0
  38. package/docs/en/plugins/official-list/_category_.json +4 -0
  39. package/docs/en/plugins/official-list/overview.md +6 -0
  40. package/docs/zh/api/config/_category_.json +4 -0
  41. package/docs/zh/api/config/build-config.md +658 -0
  42. package/docs/zh/api/{build-preset.md → config/build-preset.md} +49 -36
  43. package/docs/zh/api/config/design-system.md +1166 -0
  44. package/docs/zh/api/config/plugins.md +18 -0
  45. package/docs/zh/api/{testing.md → config/testing.md} +18 -13
  46. package/docs/zh/api/index.md +4 -1
  47. package/docs/zh/api/plugin-api/_category_.json +4 -0
  48. package/docs/zh/api/plugin-api/plugin-hooks.md +500 -0
  49. package/docs/zh/guide/advance/_category_.json +4 -0
  50. package/docs/zh/guide/advance/asset.mdx +47 -30
  51. package/docs/zh/guide/advance/build-umd.mdx +88 -71
  52. package/docs/zh/guide/advance/copy.md +31 -28
  53. package/docs/zh/guide/advance/external-dependency.mdx +27 -23
  54. package/docs/zh/guide/advance/in-depth-about-build.md +55 -50
  55. package/docs/zh/guide/advance/in-depth-about-dev-command.md +7 -4
  56. package/docs/zh/guide/advance/theme-config.mdx +78 -0
  57. package/docs/zh/guide/basic/_category_.json +4 -0
  58. package/docs/zh/guide/basic/before-getting-started.md +27 -22
  59. package/docs/zh/guide/basic/command-preview.md +17 -13
  60. package/docs/zh/guide/basic/modify-output-product.md +28 -21
  61. package/docs/zh/guide/basic/publish-your-project.md +22 -17
  62. package/docs/zh/guide/basic/test-your-project.mdx +20 -16
  63. package/docs/zh/guide/basic/use-micro-generator.md +10 -7
  64. package/docs/zh/guide/basic/using-storybook.mdx +27 -24
  65. package/docs/zh/guide/best-practices/_category_.json +4 -0
  66. package/docs/zh/guide/best-practices/components.mdx +793 -0
  67. package/docs/zh/guide/intro/_category_.json +4 -0
  68. package/docs/zh/guide/intro/getting-started.md +10 -4
  69. package/docs/zh/guide/intro/welcome.md +4 -0
  70. package/docs/zh/guide/intro/why-module-engineering-solution.md +5 -1
  71. package/docs/zh/index.md +3 -2
  72. package/docs/zh/plugins/guide/_category_.json +4 -0
  73. package/docs/zh/plugins/guide/getting-started.mdx +84 -0
  74. package/docs/zh/plugins/guide/plugin-object.mdx +85 -0
  75. package/docs/zh/plugins/guide/setup-function.mdx +117 -0
  76. package/docs/zh/plugins/official-list/_category_.json +4 -0
  77. package/docs/zh/plugins/official-list/overview.md +5 -0
  78. package/modern.config.ts +118 -0
  79. package/package.json +8 -6
  80. package/{docs/.island/styles → theme}/index.css +0 -1
  81. package/theme/index.ts +4 -0
  82. package/tsconfig.json +7 -0
  83. package/docs/.island/config.ts +0 -245
  84. package/docs/.island/dist/404.html +0 -41
  85. package/docs/.island/dist/assets/before-getting-started.1b82b538.js +0 -87
  86. package/docs/.island/dist/assets/before-getting-started.582a31cc.js +0 -87
  87. package/docs/.island/dist/assets/build-config.72eb0918.js +0 -804
  88. package/docs/.island/dist/assets/build-config.d8bb1658.js +0 -809
  89. package/docs/.island/dist/assets/build-preset.96805d7d.js +0 -256
  90. package/docs/.island/dist/assets/build-preset.c20dcd40.js +0 -256
  91. package/docs/.island/dist/assets/build-your-ui.7f349247.js +0 -2
  92. package/docs/.island/dist/assets/build-your-ui.a8361604.js +0 -2
  93. package/docs/.island/dist/assets/command-preview.2d45fc82.js +0 -264
  94. package/docs/.island/dist/assets/command-preview.dc51b953.js +0 -264
  95. package/docs/.island/dist/assets/components.esm.03560353.js +0 -9
  96. package/docs/.island/dist/assets/design-system.86694ff5.js +0 -1254
  97. package/docs/.island/dist/assets/design-system.c4745cce.js +0 -639
  98. package/docs/.island/dist/assets/dev.1d326a37.js +0 -37
  99. package/docs/.island/dist/assets/dev.1fd06000.js +0 -37
  100. package/docs/.island/dist/assets/down.f35427d3.svg +0 -1
  101. package/docs/.island/dist/assets/extension.12299fd6.js +0 -2
  102. package/docs/.island/dist/assets/extension.96dc63a4.js +0 -2
  103. package/docs/.island/dist/assets/getting-started.40e9218d.js +0 -117
  104. package/docs/.island/dist/assets/getting-started.b1ed3f10.js +0 -114
  105. package/docs/.island/dist/assets/github.3bf8ccee.svg +0 -1
  106. package/docs/.island/dist/assets/index.2b2347ea.js +0 -33
  107. package/docs/.island/dist/assets/index.6cef6f5f.js +0 -4
  108. package/docs/.island/dist/assets/index.cb118238.js +0 -36
  109. package/docs/.island/dist/assets/index.ccb6ce27.js +0 -4
  110. package/docs/.island/dist/assets/island_inject.11a12ecc.js +0 -1
  111. package/docs/.island/dist/assets/island_inject.b13deaee.js +0 -1
  112. package/docs/.island/dist/assets/loading.8c9bb911.svg +0 -1
  113. package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +0 -100
  114. package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +0 -100
  115. package/docs/.island/dist/assets/moon.6b705924.svg +0 -3
  116. package/docs/.island/dist/assets/plugin.895932d8.js +0 -42
  117. package/docs/.island/dist/assets/plugin.d2fbc531.js +0 -42
  118. package/docs/.island/dist/assets/publish-your-project.21b8309f.js +0 -164
  119. package/docs/.island/dist/assets/publish-your-project.8d398b17.js +0 -166
  120. package/docs/.island/dist/assets/right.89674cd7.svg +0 -1
  121. package/docs/.island/dist/assets/search.0aea6901.svg +0 -1
  122. package/docs/.island/dist/assets/search.1c85d17c.js +0 -3
  123. package/docs/.island/dist/assets/search.484eca11.js +0 -222
  124. package/docs/.island/dist/assets/search.54fca8d0.js +0 -3
  125. package/docs/.island/dist/assets/style.09015a4b.css +0 -1
  126. package/docs/.island/dist/assets/style.2e5f7bc2.css +0 -1970
  127. package/docs/.island/dist/assets/sun.841dac10.svg +0 -11
  128. package/docs/.island/dist/assets/test-your-project.18bd4582.js +0 -190
  129. package/docs/.island/dist/assets/test-your-project.f53bebf7.js +0 -190
  130. package/docs/.island/dist/assets/test.0da1f99f.js +0 -67
  131. package/docs/.island/dist/assets/test.0e81f002.js +0 -66
  132. package/docs/.island/dist/assets/translator.b1077c44.svg +0 -1
  133. package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +0 -60
  134. package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +0 -60
  135. package/docs/.island/dist/assets/using-storybook.57ea6b77.js +0 -260
  136. package/docs/.island/dist/assets/using-storybook.a2212f2e.js +0 -260
  137. package/docs/.island/dist/assets/welcome.0449a9c8.js +0 -13
  138. package/docs/.island/dist/assets/welcome.a8448931.js +0 -13
  139. package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +0 -26
  140. package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +0 -26
  141. package/docs/.island/dist/chunk-COLCRJ2V.js +0 -1
  142. package/docs/.island/dist/chunk-K5FMOYDC.js +0 -10
  143. package/docs/.island/dist/chunk-WE42KMYS.js +0 -26
  144. package/docs/.island/dist/client-entry.js +0 -3
  145. package/docs/.island/dist/en/api/build-config.html +0 -344
  146. package/docs/.island/dist/en/api/build-preset.html +0 -82
  147. package/docs/.island/dist/en/api/design-system.html +0 -155
  148. package/docs/.island/dist/en/api/dev.html +0 -45
  149. package/docs/.island/dist/en/api/index.html +0 -41
  150. package/docs/.island/dist/en/api/plugin.html +0 -48
  151. package/docs/.island/dist/en/api/test.html +0 -58
  152. package/docs/.island/dist/en/guide/before-getting-started.html +0 -127
  153. package/docs/.island/dist/en/guide/build-your-ui.html +0 -41
  154. package/docs/.island/dist/en/guide/command-preview.html +0 -100
  155. package/docs/.island/dist/en/guide/extension.html +0 -41
  156. package/docs/.island/dist/en/guide/getting-started.html +0 -76
  157. package/docs/.island/dist/en/guide/modify-output-product.html +0 -140
  158. package/docs/.island/dist/en/guide/publish-your-project.html +0 -91
  159. package/docs/.island/dist/en/guide/test-your-project.html +0 -72
  160. package/docs/.island/dist/en/guide/use-micro-generator.html +0 -65
  161. package/docs/.island/dist/en/guide/using-storybook.html +0 -113
  162. package/docs/.island/dist/en/guide/welcome.html +0 -53
  163. package/docs/.island/dist/en/guide/why-module-engineering-solution.html +0 -49
  164. package/docs/.island/dist/en/index.html +0 -42
  165. package/docs/.island/dist/react-dom.js +0 -1
  166. package/docs/.island/dist/react-dom_client.js +0 -1
  167. package/docs/.island/dist/react.js +0 -1
  168. package/docs/.island/dist/react_jsx-runtime.js +0 -10
  169. package/docs/.island/dist/ssr-manifest.json +0 -57
  170. package/docs/.island/dist/test-result.png +0 -0
  171. package/docs/.island/dist/why-module-solution.png +0 -0
  172. package/docs/.island/dist/zh/api/build-config.html +0 -347
  173. package/docs/.island/dist/zh/api/build-preset.html +0 -82
  174. package/docs/.island/dist/zh/api/design-system.html +0 -149
  175. package/docs/.island/dist/zh/api/dev.html +0 -46
  176. package/docs/.island/dist/zh/api/index.html +0 -41
  177. package/docs/.island/dist/zh/api/plugin.html +0 -48
  178. package/docs/.island/dist/zh/api/test.html +0 -59
  179. package/docs/.island/dist/zh/guide/before-getting-started.html +0 -127
  180. package/docs/.island/dist/zh/guide/build-your-ui.html +0 -41
  181. package/docs/.island/dist/zh/guide/command-preview.html +0 -100
  182. package/docs/.island/dist/zh/guide/extension.html +0 -41
  183. package/docs/.island/dist/zh/guide/getting-started.html +0 -79
  184. package/docs/.island/dist/zh/guide/modify-output-product.html +0 -140
  185. package/docs/.island/dist/zh/guide/publish-your-project.html +0 -92
  186. package/docs/.island/dist/zh/guide/test-your-project.html +0 -72
  187. package/docs/.island/dist/zh/guide/use-micro-generator.html +0 -65
  188. package/docs/.island/dist/zh/guide/using-storybook.html +0 -114
  189. package/docs/.island/dist/zh/guide/welcome.html +0 -53
  190. package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +0 -49
  191. package/docs/.island/dist/zh/index.html +0 -42
  192. package/docs/.island/index.html +0 -39
  193. package/docs/en/api/design-system.md +0 -524
  194. package/docs/en/api/dev.md +0 -32
  195. package/docs/en/api/plugin.md +0 -34
  196. package/docs/zh/api/build-config.md +0 -570
  197. package/docs/zh/api/dev.md +0 -33
  198. package/docs/zh/api/plugins.md +0 -108
package/.eslintrc.js ADDED
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@modern-js'],
4
+ parserOptions: {
5
+ tsconfigRootDir: __dirname,
6
+ project: ['./tsconfig.json'],
7
+ },
8
+ ignorePatterns: ['modern.config.ts'],
9
+ rules: {
10
+ 'babel/no-unused-expressions': 0,
11
+ 'react/jsx-filename-extension': 0,
12
+ },
13
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "Config",
3
+ "collapsed": false
4
+ }
@@ -1,6 +1,13 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
1
5
  # BuildConfig
6
+
2
7
  This section describes all the configuration of Module tools for building
8
+
3
9
  ## alias
10
+
4
11
  - type: `Record<string, string | string[]> | Function`
5
12
  - default: `{'@': 'src',}`
6
13
 
@@ -8,9 +15,9 @@ This section describes all the configuration of Module tools for building
8
15
  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
16
  :::
10
17
 
11
- ```js
18
+ ```js modern.config.ts
12
19
  export default {
13
- build: {
20
+ buildConfig: {
14
21
  alias: {
15
22
  '@common': '. /src/common',
16
23
  },
@@ -22,9 +29,9 @@ After the above configuration is done, if `@common/Foo.tsx` is referenced in the
22
29
 
23
30
  When the value of `alias` is defined as a function, you can accept the pre-defined alias object and modify it.
24
31
 
25
- ```js
32
+ ```js modern.config.ts
26
33
  export default {
27
- build: {
34
+ buildConfig: {
28
35
  alias: alias => {
29
36
  alias['@common'] = '. /src/common';
30
37
  },
@@ -34,9 +41,9 @@ export default {
34
41
 
35
42
  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
43
 
37
- ```js
44
+ ```js modern.config.ts
38
45
  export default {
39
- build: {
46
+ buildConfig: {
40
47
  alias: alias => {
41
48
  return {
42
49
  '@common': '. /src/common',
@@ -49,93 +56,118 @@ export default {
49
56
  ## asset
50
57
 
51
58
  ### path
52
- Static resource output path, will be based on [outdir](/zh/api/build-config/#outdir)
59
+
60
+ Static resource output path, will be based on [outDir](/zh/api/build-config/#outDir)
53
61
 
54
62
  - type: `string`
55
63
  - default: `assets`
56
64
 
57
65
  ### limit
58
- Threshold for automatically inlining static resources when building, resources less than 10240 bytes will be automatically inlined into the bundle product
66
+
67
+ Threshold for automatically inlining static resources when building, resources less than 10 KB will be automatically inlined into the bundle product
59
68
 
60
69
  - type: `number`
61
70
  - default: `10 * 1024`
62
71
 
63
72
  ### publicPath
73
+
64
74
  The CDN prefix given to unlinked resources when packaging
75
+
65
76
  - type: `string`
66
77
  - default: `undefined`
67
- ```js
78
+
79
+ ```js modern.config.ts
68
80
  export default {
69
- build: {
81
+ buildConfig: {
70
82
  asset: {
71
- publicPath: 'https://xxx/'
72
- }
73
- }
83
+ publicPath: 'https://xxx/',
84
+ },
85
+ },
74
86
  };
75
87
  ```
88
+
76
89
  At this point, all static resources will be prefixed with `https://xxx/`
77
90
 
78
91
  ### svgr
79
- Treat svg as a React component when packaging
92
+
93
+ Packaged to handle svg as a React component, options reference [svgr](https://react-svgr.com/docs/options/), plus support for two configuration items `include` and `exclude` to match the svg file to be handled
94
+
80
95
  - type: `boolean | Object`
96
+ - default: `false`
81
97
 
82
98
  #### include
99
+
83
100
  Set the matching svg file
101
+
84
102
  - type: `string | RegExp | (string | RegExp)[]`
85
103
  - default: `/\.svg$/`
86
104
 
87
105
  #### exclude
106
+
88
107
  Set unmatched svg files
108
+
89
109
  - type: `string | RegExp | (string | RegExp)[]`
90
110
  - default: `undefined`
91
111
 
92
-
93
112
  ## autoExternal
113
+
94
114
  Automatically externalize project dependencies and peerDependencies and not package them into the final bundle
115
+
95
116
  - type: `boolean | Object`
96
117
  - default: `true`
97
118
 
98
119
  ### dependencies
120
+
99
121
  Whether or not the dep dependencies of the external project are needed
122
+
100
123
  - type: `boolean`
101
124
  - default: `true`
102
125
 
103
126
  ### peerDependencies
127
+
104
128
  Whether to require peerDep dependencies for external projects
129
+
105
130
  - type: `boolean`
106
131
  - default: `true`
107
132
 
108
133
  ## buildType
134
+
109
135
  The build type, `bundle` will package your code, `bundleless` will only do the code conversion
136
+
110
137
  - type: `'bundle' | 'bundleless'`
111
138
  - default: `bundle`
112
139
 
113
140
  ## copy
141
+
114
142
  Copies the specified file or directory into the build output directory
143
+
115
144
  - type: `Array`
116
145
  - default: `[]`
117
- ``js
118
146
 
147
+ ```js
119
148
  export default {
120
- build: {
149
+ buildConfig: {
121
150
  copy: [{ from: '. /src/assets', to: '' }],
122
151
  },
123
152
  };
124
153
  ```
154
+
125
155
  Reference for array settings: [copy-webpack-plugin patterns](https://github.com/webpack-contrib/copy-webpack-plugin#patterns)
126
156
 
127
157
  ## define
158
+
128
159
  Define global variables that will be injected into the code
160
+
129
161
  - type: `Record<string, string>`
130
162
  - default: `{}`
131
163
 
132
164
  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
165
+
166
+ ```js modern.config.ts
134
167
  export default {
135
- build: {
168
+ buildConfig: {
136
169
  define: {
137
- 'VERSION': JSON.stringify('1.0'),
138
-
170
+ VERSION: JSON.stringify('1.0'),
139
171
  },
140
172
  },
141
173
  };
@@ -143,66 +175,85 @@ export default {
143
175
 
144
176
  :::tip
145
177
  To prevent excessive global replacement substitution, it is recommended that the following two principles be followed when using
178
+
146
179
  - Use upper case for global constants
147
180
  - Customize the prefix and suffix of global constants to ensure uniqueness
148
- :::
181
+ :::
149
182
 
150
183
  ## dts
184
+
151
185
  The dts file generates the relevant configuration, by default it generates
152
186
 
153
187
  - type: `false | Object`
154
188
  - default: `{}`
155
189
 
156
190
  ### tsconfigPath
191
+
157
192
  Path to the tsconfig file
193
+
158
194
  - type: `string`
159
195
  - default: `. /tsconfig.json`
160
196
 
161
197
  ### distPath
162
- The output path of the dts file, based on [outdir]('/zh/api/build-config/#outdir')
198
+
199
+ The output path of the dts file, based on [outDir](/zh/api/build-config/#outDir)
200
+
163
201
  - type: `string`
164
202
  - default: `. /types`
165
203
 
166
204
  ### only
205
+
167
206
  Generate only dts files, not js files
207
+
168
208
  - type: `boolean`
169
209
  - default: `false`
170
210
 
171
211
  ## externals
212
+
172
213
  Configure external dependencies that will not be packaged into the final bundle
214
+
173
215
  - type: `(string | RegExp)[]`
174
216
  - default: `[]`
217
+
175
218
  ## format
219
+
176
220
  The format of the js product output, where `iife` and `umd` can only take effect when `buildType` is `bundle`
221
+
177
222
  - type: `'esm' | 'cjs' | 'iife' | 'umd'`
178
223
  - default: `cjs`
179
224
 
180
225
  ## input
226
+
181
227
  Specify the entry file for the build, in the form of an array that can specify the directory
228
+
182
229
  - type: `string[] | Record<string, string>`
183
230
  - default: `['src/index.ts']` in `bundle` mode, `['src']` in `bundleless` mode
184
231
 
185
- ```js
232
+ ```js modern.config.ts
186
233
  export default {
187
- build: {
234
+ buildConfig: {
188
235
  input: ['src/index.ts', 'src/index2.ts'],
189
236
  },
190
237
  };
191
238
  ```
192
239
 
193
240
  ## jsx
241
+
194
242
  Specify the compilation method of jsx, default support React17, automatically inject jsx runtime code
243
+
195
244
  - type: `automatic | classic`
196
245
  - default: `automatic`
197
246
 
198
247
  ## minify
248
+
199
249
  Use esbuild or terser to compress code, also pass [terserOptions](https://github.com/terser/terser#minify-options)
250
+
200
251
  - type: `'terser' | 'esbuild' | false | Object`
201
252
  - default: `false`
202
253
 
203
- ```js
254
+ ```js modern.config.ts
204
255
  export default {
205
- build: {
256
+ buildConfig: {
206
257
  minify: {
207
258
  compress: {
208
259
  drop_console: true,
@@ -212,155 +263,192 @@ export default {
212
263
  };
213
264
  ```
214
265
 
215
- ## outdir
266
+ ## outDir
267
+
216
268
  Specifies the output directory of the build
269
+
217
270
  - type: `string`
218
271
  - default: `dist`
219
272
 
220
273
  ## platform
274
+
221
275
  Generates code for the node environment by default, you can also specify `browser` which will generate code for the browser environment
276
+
222
277
  - type: `'browser' | 'node'`
223
278
  - default: `node`
224
279
 
225
280
  ## sourceDir
281
+
226
282
  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`.
283
+
227
284
  - type: `string`
228
285
  - default: `src`
229
286
 
230
287
  ## sourceMap
288
+
231
289
  Whether to generate sourceMap or not
290
+
232
291
  - type: `boolean | 'inline' | 'external'`
233
292
  - default: `false`
234
293
 
235
294
  ## splitting
295
+
236
296
  Whether to enable code splitting
297
+
237
298
  - type: `boolean`
238
299
  - default: `false`
239
300
 
240
301
  ## style
302
+
241
303
  Configure style-related configuration
242
304
 
243
305
  ### less
306
+
244
307
  less-related configuration
308
+
245
309
  #### lessOptions
310
+
246
311
  Refer to [less](https://less.bootcss.com/usage/#less-options) for detailed configuration
312
+
247
313
  - type: `Object`
248
314
  - default: `{ javascriptEnabled: true }`
249
315
 
250
316
  #### additionalData
317
+
251
318
  Add `Less` code to the beginning of the entry file.
319
+
252
320
  - type: `string`
253
321
  - default: `undefined`
254
322
 
255
- ```js
323
+ ```js modern.config.ts
256
324
  export default {
257
- build: {
325
+ buildConfig: {
258
326
  style: {
259
327
  less: {
260
328
  additionalData: `@base-color: #c6538c;`,
261
329
  },
262
- }
263
- }
264
- }
265
-
330
+ },
331
+ },
332
+ };
266
333
  ```
334
+
267
335
  #### implementation
336
+
268
337
  Configure the implementation library used by `Less`, if not specified, the built-in version used is `4.1.3`
338
+
269
339
  - type: `string | Object`
270
340
  - default: `undefined`
271
341
 
272
342
  Specify the implementation library for `Less` when the `Object` type is specified
273
- ```js
343
+
344
+ ```js modern.config.ts
274
345
  export default {
275
- build: {
346
+ buildConfig: {
276
347
  style: {
277
348
  less: {
278
349
  implementation: require('less'),
279
350
  },
280
- }
281
- }
282
- }
351
+ },
352
+ },
353
+ };
283
354
  ```
284
355
 
285
356
  For the `string` type, specify the path to the implementation library for `Less`
286
- ```js
357
+
358
+ ```js modern.config.ts
287
359
  export default {
288
- build: {
360
+ buildConfig: {
289
361
  style: {
290
362
  less: {
291
363
  implementation: require.resolve('less'),
292
364
  },
293
- }
294
- }
295
- }
365
+ },
366
+ },
367
+ };
296
368
  ```
297
369
 
298
370
  ### sass
371
+
299
372
  sass-related configuration
373
+
300
374
  #### sassOptions
375
+
301
376
  Refer to [node-sass](https://github.com/sass/node-sass#options) for detailed configuration
377
+
302
378
  - type: `Object`
303
379
  - default: `{}`
380
+
304
381
  #### additionalData
382
+
305
383
  Add `Sass` code to the beginning of the entry file.
384
+
306
385
  - type: `string | Function`
307
386
  - default: `undefined`
308
- ```js
387
+
388
+ ```js modern.config.ts
309
389
  export default {
310
- build: {
390
+ buildConfig: {
311
391
  style: {
312
392
  sass: {
313
393
  additionalData: `$base-color: #c6538c;
314
394
  $border-dark: rgba($base-color, 0.88);`,
315
395
  },
316
- }
317
- }
318
- }
396
+ },
397
+ },
398
+ };
319
399
  ```
320
400
 
321
401
  #### implementation
402
+
322
403
  Configure the implementation library used by `Sass`, the built-in version used is `1.5.4` if not specified
404
+
323
405
  - type: `string | Object`
324
406
  - default: `undefined`
325
407
 
326
408
  Specify the implementation library for `Sass` when the `Object` type is specified
327
- ```js
409
+
410
+ ```js modern.config.ts
328
411
  export default {
329
- build: {
412
+ buildConfig: {
330
413
  style: {
331
414
  sass: {
332
415
  implementation: require('sass'),
333
416
  },
334
- }
335
- }
336
- }
417
+ },
418
+ },
419
+ };
337
420
  ```
338
421
 
339
422
  For the `string` type, specify the path to the `Sass` implementation library
340
- ```js
423
+
424
+ ```js modern.config.ts
341
425
  export default {
342
- build: {
426
+ buildConfig: {
343
427
  style: {
344
428
  sass: {
345
429
  implementation: require.resolve('sass'),
346
430
  },
347
- }
348
- }
349
- }
431
+ },
432
+ },
433
+ };
350
434
  ```
351
435
 
352
436
  ### postcss
437
+
353
438
  - plugins
354
439
  - processOptions
355
440
 
356
441
  See [postcss](https://github.com/postcss/postcss#options) for detailed configuration
442
+
357
443
  ### inject
444
+
358
445
  Configure whether to insert style into js in packaged mode
359
446
 
360
447
  - type: `boolean`
361
448
  - default: `false`
362
449
 
363
450
  ### autoModules
451
+
364
452
  Enable CSS Modules automatically based on the filename.
365
453
 
366
454
  - type: `boolean | RegExp`
@@ -373,63 +461,61 @@ Enable CSS Modules automatically based on the filename.
373
461
  `RegExp` : Enables CSS Modules for all files that match the regular condition.
374
462
 
375
463
  ### modules
464
+
376
465
  CSS Modules configuration
377
466
 
378
467
  - type: `Object`
379
468
  - default: `{}`
380
469
 
381
- A common configuration is ``localsConvention``, which changes the class name generation rules for css modules
382
- ```js
470
+ A common configuration is `localsConvention`, which changes the class name generation rules for css modules
471
+
472
+ ```js modern.config.ts
383
473
  export default {
384
- build: {
474
+ buildConfig: {
385
475
  style: {
386
476
  modules: {
387
477
  localsConvention: 'camelCaseOnly',
388
478
  },
389
- }
390
- }
391
- }
479
+ },
480
+ },
481
+ };
392
482
  ```
483
+
393
484
  For the following styles
485
+
394
486
  ```css
395
487
  .box-title {
396
488
  color: red;
397
489
  }
398
490
  ```
399
- You can use ``styles.boxTitle`` to access
400
491
 
492
+ You can use `styles.boxTitle` to access
401
493
 
402
494
  For detailed configuration see [postcss-modules](https://github.com/madyankin/postcss-modules#usage)
403
495
 
404
- ### tailwind
496
+ ### tailwindcss
497
+
405
498
  tailwindcss related configuration
406
499
 
407
500
  - type: `Object | Function`
408
501
  - default: `see configuration details below`
409
502
 
410
503
  <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
- }
504
+ <summary>Tailwind CSS configuration details</summary>
505
+
506
+ ```js modern.config.ts
507
+ const tailwind = {
508
+ content: [
509
+ './config/html/**/*.html',
510
+ './config/html/**/*.ejs',
511
+ './config/html/**/*.hbs',
512
+ './src/**/*.js',
513
+ './src/**/*.jsx',
514
+ './src/**/*.ts',
515
+ './src/**/*.tsx',
516
+ './storybook/**/*',
517
+ ],
518
+ };
433
519
  ```
434
520
 
435
521
  When the value is of type `Object`, it is merged with the default configuration via `Object.assign`.
@@ -440,62 +526,69 @@ The `theme` property is not allowed, otherwise the build will fail, using [`desi
440
526
 
441
527
  The rest of the usage is the same as Tailwind CSS: [Quick Portal](https://tailwindcss.com/docs/configuration).
442
528
 
443
-
444
529
  ## target
530
+
445
531
  Specify the target environment for the build
532
+
446
533
  - type: `'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext'`
447
534
  - default: `'es2015'`
448
535
 
449
-
450
536
  ## umdGlobals
537
+
451
538
  Specify global variables for external import of umd products
539
+
452
540
  - type: `Record<string, string>`
453
541
  - default: `{}`
454
542
 
455
- ```js
543
+ ```js modern.config.ts
456
544
  export default {
457
- build: {
545
+ buildConfig: {
458
546
  umdGlobals: {
459
547
  react: 'React',
460
548
  'react-dom': 'ReactDOM',
461
549
  },
462
- }
463
- }
550
+ },
551
+ };
464
552
  ```
553
+
465
554
  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
555
 
467
556
  ## umdModuleName
557
+
468
558
  Specifies the module name of the umd product
469
559
 
470
560
  - type: `string` | `Function`
471
561
  - default: `name => name`
472
562
 
473
- ``js
563
+ ```js
474
564
  export default {
475
- build: {
565
+ buildConfig: {
476
566
  format: 'umd',
477
567
  umdModuleName: 'myLib',
478
- }
479
- }
568
+ },
569
+ };
480
570
  ```
571
+
481
572
  At this point the umd product will go to mount on `global.myLib`
482
573
  :::tip
574
+
483
575
  - The module name of the umd product must not conflict with the global variable name.
484
576
  - Module names should not contain special characters like `-`, `@`, `/`, etc.
485
- :::
577
+ :::
486
578
 
487
579
  Also the function form can take one parameter, which is the output path of the current package file
488
- ```js
580
+
581
+ ```js modern.config.ts
489
582
  export default {
490
- build: {
583
+ buildConfig: {
491
584
  format: 'umd',
492
- umdModuleName: (path) => {
585
+ umdModuleName: path => {
493
586
  if (path.includes('index')) {
494
587
  return 'myLib';
495
588
  } else {
496
589
  return 'myLib2';
497
590
  }
498
591
  },
499
- }
500
- }
592
+ },
593
+ };
501
594
  ```