@modern-js/module-tools-docs 2.0.1 → 2.0.2
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/doc_build/html/main/index.html +16 -0
- package/doc_build/route.json +10 -0
- package/doc_build/static/css/main.css +3370 -0
- package/doc_build/static/css/main.css.map +1 -0
- package/doc_build/static/css/vendors-node_modules_pnpm_remix-run_router_1_2_0_node_modules_remix-run_router_dist_router_js-9d5e9c.css +85 -0
- package/doc_build/static/css/vendors-node_modules_pnpm_remix-run_router_1_2_0_node_modules_remix-run_router_dist_router_js-9d5e9c.css.map +1 -0
- package/doc_build/static/js/async/api_.js +56 -0
- package/doc_build/static/js/async/api_.js.map +1 -0
- package/doc_build/static/js/async/api_config_build-config.js +11309 -0
- package/doc_build/static/js/async/api_config_build-config.js.map +1 -0
- package/doc_build/static/js/async/api_config_build-preset.js +7849 -0
- package/doc_build/static/js/async/api_config_build-preset.js.map +1 -0
- package/doc_build/static/js/async/api_config_design-system.js +48708 -0
- package/doc_build/static/js/async/api_config_design-system.js.map +1 -0
- package/doc_build/static/js/async/api_config_plugins.js +1492 -0
- package/doc_build/static/js/async/api_config_plugins.js.map +1 -0
- package/doc_build/static/js/async/api_config_testing.js +2130 -0
- package/doc_build/static/js/async/api_config_testing.js.map +1 -0
- package/doc_build/static/js/async/api_plugin-api_plugin-hooks.js +14394 -0
- package/doc_build/static/js/async/api_plugin-api_plugin-hooks.js.map +1 -0
- package/doc_build/static/js/async/en_.js +85 -0
- package/doc_build/static/js/async/en_.js.map +1 -0
- package/doc_build/static/js/async/en_api_.js +55 -0
- package/doc_build/static/js/async/en_api_.js.map +1 -0
- package/doc_build/static/js/async/en_api_config_build-config.js +8363 -0
- package/doc_build/static/js/async/en_api_config_build-config.js.map +1 -0
- package/doc_build/static/js/async/en_api_config_build-preset.js +7845 -0
- package/doc_build/static/js/async/en_api_config_build-preset.js.map +1 -0
- package/doc_build/static/js/async/en_api_config_design-system.js +16345 -0
- package/doc_build/static/js/async/en_api_config_design-system.js.map +1 -0
- package/doc_build/static/js/async/en_api_config_plugins.js +1492 -0
- package/doc_build/static/js/async/en_api_config_plugins.js.map +1 -0
- package/doc_build/static/js/async/en_api_config_testing.js +2137 -0
- package/doc_build/static/js/async/en_api_config_testing.js.map +1 -0
- package/doc_build/static/js/async/en_api_plugin-api_plugin-hooks.js +14362 -0
- package/doc_build/static/js/async/en_api_plugin-api_plugin-hooks.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_asset.js +3997 -0
- package/doc_build/static/js/async/en_guide_advance_asset.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_build-umd.js +9861 -0
- package/doc_build/static/js/async/en_guide_advance_build-umd.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_copy.js +6539 -0
- package/doc_build/static/js/async/en_guide_advance_copy.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_external-dependency.js +3810 -0
- package/doc_build/static/js/async/en_guide_advance_external-dependency.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_in-depth-about-build.js +5046 -0
- package/doc_build/static/js/async/en_guide_advance_in-depth-about-build.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_in-depth-about-dev-command.js +150 -0
- package/doc_build/static/js/async/en_guide_advance_in-depth-about-dev-command.js.map +1 -0
- package/doc_build/static/js/async/en_guide_advance_theme-config.js +2484 -0
- package/doc_build/static/js/async/en_guide_advance_theme-config.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_before-getting-started.js +3671 -0
- package/doc_build/static/js/async/en_guide_basic_before-getting-started.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_command-preview.js +3961 -0
- package/doc_build/static/js/async/en_guide_basic_command-preview.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_modify-output-product.js +2970 -0
- package/doc_build/static/js/async/en_guide_basic_modify-output-product.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_publish-your-project.js +2182 -0
- package/doc_build/static/js/async/en_guide_basic_publish-your-project.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_test-your-project.js +3892 -0
- package/doc_build/static/js/async/en_guide_basic_test-your-project.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_use-micro-generator.js +168 -0
- package/doc_build/static/js/async/en_guide_basic_use-micro-generator.js.map +1 -0
- package/doc_build/static/js/async/en_guide_basic_using-storybook.js +4762 -0
- package/doc_build/static/js/async/en_guide_basic_using-storybook.js.map +1 -0
- package/doc_build/static/js/async/en_guide_best-practices_components.js +21388 -0
- package/doc_build/static/js/async/en_guide_best-practices_components.js.map +1 -0
- package/doc_build/static/js/async/en_guide_intro_getting-started.js +1906 -0
- package/doc_build/static/js/async/en_guide_intro_getting-started.js.map +1 -0
- package/doc_build/static/js/async/en_guide_intro_welcome.js +148 -0
- package/doc_build/static/js/async/en_guide_intro_welcome.js.map +1 -0
- package/doc_build/static/js/async/en_guide_intro_why-module-engineering-solution.js +92 -0
- package/doc_build/static/js/async/en_guide_intro_why-module-engineering-solution.js.map +1 -0
- package/doc_build/static/js/async/en_plugins_guide_getting-started.js +2560 -0
- package/doc_build/static/js/async/en_plugins_guide_getting-started.js.map +1 -0
- package/doc_build/static/js/async/en_plugins_guide_plugin-object.js +4177 -0
- package/doc_build/static/js/async/en_plugins_guide_plugin-object.js.map +1 -0
- package/doc_build/static/js/async/en_plugins_guide_setup-function.js +3819 -0
- package/doc_build/static/js/async/en_plugins_guide_setup-function.js.map +1 -0
- package/doc_build/static/js/async/en_plugins_official-list_overview.js +70 -0
- package/doc_build/static/js/async/en_plugins_official-list_overview.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_asset.js +3997 -0
- package/doc_build/static/js/async/guide_advance_asset.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_build-umd.js +9863 -0
- package/doc_build/static/js/async/guide_advance_build-umd.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_copy.js +6539 -0
- package/doc_build/static/js/async/guide_advance_copy.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_external-dependency.js +3812 -0
- package/doc_build/static/js/async/guide_advance_external-dependency.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_in-depth-about-build.js +5046 -0
- package/doc_build/static/js/async/guide_advance_in-depth-about-build.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_in-depth-about-dev-command.js +152 -0
- package/doc_build/static/js/async/guide_advance_in-depth-about-dev-command.js.map +1 -0
- package/doc_build/static/js/async/guide_advance_theme-config.js +2475 -0
- package/doc_build/static/js/async/guide_advance_theme-config.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_before-getting-started.js +3662 -0
- package/doc_build/static/js/async/guide_basic_before-getting-started.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_command-preview.js +3793 -0
- package/doc_build/static/js/async/guide_basic_command-preview.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_modify-output-product.js +2949 -0
- package/doc_build/static/js/async/guide_basic_modify-output-product.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_publish-your-project.js +2243 -0
- package/doc_build/static/js/async/guide_basic_publish-your-project.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_test-your-project.js +3892 -0
- package/doc_build/static/js/async/guide_basic_test-your-project.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_use-micro-generator.js +172 -0
- package/doc_build/static/js/async/guide_basic_use-micro-generator.js.map +1 -0
- package/doc_build/static/js/async/guide_basic_using-storybook.js +4762 -0
- package/doc_build/static/js/async/guide_basic_using-storybook.js.map +1 -0
- package/doc_build/static/js/async/guide_best-practices_components.js +21088 -0
- package/doc_build/static/js/async/guide_best-practices_components.js.map +1 -0
- package/doc_build/static/js/async/guide_intro_getting-started.js +1782 -0
- package/doc_build/static/js/async/guide_intro_getting-started.js.map +1 -0
- package/doc_build/static/js/async/guide_intro_welcome.js +148 -0
- package/doc_build/static/js/async/guide_intro_welcome.js.map +1 -0
- package/doc_build/static/js/async/guide_intro_why-module-engineering-solution.js +92 -0
- package/doc_build/static/js/async/guide_intro_why-module-engineering-solution.js.map +1 -0
- package/doc_build/static/js/async/index.js +85 -0
- package/doc_build/static/js/async/index.js.map +1 -0
- package/doc_build/static/js/async/packages_cli_doc-core_src_theme-default_components_Search_logic_search_ts.js +447 -0
- package/doc_build/static/js/async/packages_cli_doc-core_src_theme-default_components_Search_logic_search_ts.js.map +1 -0
- package/doc_build/static/js/async/plugins_guide_getting-started.js +2608 -0
- package/doc_build/static/js/async/plugins_guide_getting-started.js.map +1 -0
- package/doc_build/static/js/async/plugins_guide_plugin-object.js +4173 -0
- package/doc_build/static/js/async/plugins_guide_plugin-object.js.map +1 -0
- package/doc_build/static/js/async/plugins_guide_setup-function.js +3819 -0
- package/doc_build/static/js/async/plugins_guide_setup-function.js.map +1 -0
- package/doc_build/static/js/async/plugins_official-list_overview.js +70 -0
- package/doc_build/static/js/async/plugins_official-list_overview.js.map +1 -0
- package/doc_build/static/js/async/vendors-node_modules_pnpm_code-hike_mdx_0_7_4_react_18_2_0_node_modules_code-hike_mdx_dist_co-06dd41.js +6656 -0
- package/doc_build/static/js/async/vendors-node_modules_pnpm_code-hike_mdx_0_7_4_react_18_2_0_node_modules_code-hike_mdx_dist_co-06dd41.js.map +1 -0
- package/doc_build/static/js/async/vendors-node_modules_pnpm_flexsearch_0_6_32_node_modules_flexsearch_dist_flexsearch_min_js.js +54 -0
- package/doc_build/static/js/async/vendors-node_modules_pnpm_flexsearch_0_6_32_node_modules_flexsearch_dist_flexsearch_min_js.js.map +1 -0
- package/doc_build/static/js/builder-runtime.js +1375 -0
- package/doc_build/static/js/builder-runtime.js.map +1 -0
- package/doc_build/static/js/lib-lodash.js +4907 -0
- package/doc_build/static/js/lib-lodash.js.map +1 -0
- package/doc_build/static/js/lib-polyfill.js +24769 -0
- package/doc_build/static/js/lib-polyfill.js.map +1 -0
- package/doc_build/static/js/lib-react.js +39510 -0
- package/doc_build/static/js/lib-react.js.map +1 -0
- package/doc_build/static/js/main.js +9237 -0
- package/doc_build/static/js/main.js.map +1 -0
- package/doc_build/static/js/vendors-node_modules_pnpm_remix-run_router_1_2_0_node_modules_remix-run_router_dist_router_js-9d5e9c.js +8532 -0
- package/doc_build/static/js/vendors-node_modules_pnpm_remix-run_router_1_2_0_node_modules_remix-run_router_dist_router_js-9d5e9c.js.map +1 -0
- package/docs/en/api/config/build-config.md +5 -5
- package/docs/en/api/plugin-api/plugin-hooks.md +1 -1
- package/docs/en/guide/advance/asset.mdx +1 -1
- package/docs/en/guide/advance/build-umd.mdx +3 -3
- package/docs/en/guide/advance/copy.md +5 -5
- package/docs/en/guide/advance/external-dependency.mdx +2 -2
- package/docs/en/guide/advance/in-depth-about-build.md +7 -7
- package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/en/guide/advance/theme-config.mdx +2 -2
- package/docs/en/guide/basic/before-getting-started.md +1 -1
- package/docs/en/guide/basic/command-preview.md +2 -2
- package/docs/en/guide/basic/modify-output-product.md +23 -22
- package/docs/en/guide/basic/publish-your-project.md +4 -4
- package/docs/en/guide/basic/test-your-project.mdx +5 -3
- package/docs/en/guide/basic/use-micro-generator.md +9 -5
- package/docs/en/guide/basic/using-storybook.mdx +6 -4
- package/docs/en/guide/best-practices/components.mdx +103 -97
- package/docs/en/guide/intro/getting-started.md +2 -2
- package/docs/en/index.md +14 -17
- package/docs/en/plugins/guide/getting-started.mdx +2 -2
- package/docs/en/plugins/guide/setup-function.mdx +2 -2
- package/docs/zh/api/config/_category_.json +1 -1
- package/docs/zh/api/config/build-config.md +16 -5
- package/docs/zh/api/config/plugins.md +1 -1
- package/docs/zh/api/index.md +1 -0
- package/docs/zh/api/plugin-api/_category_.json +1 -1
- package/docs/zh/api/plugin-api/plugin-hooks.md +56 -55
- package/docs/zh/guide/advance/asset.mdx +1 -1
- package/docs/zh/guide/advance/build-umd.mdx +3 -3
- package/docs/zh/guide/advance/copy.md +5 -5
- package/docs/zh/guide/advance/external-dependency.mdx +3 -3
- package/docs/zh/guide/advance/in-depth-about-build.md +7 -7
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/zh/guide/advance/theme-config.mdx +2 -2
- package/docs/zh/guide/basic/before-getting-started.md +1 -1
- package/docs/zh/guide/basic/command-preview.md +2 -2
- package/docs/zh/guide/basic/modify-output-product.md +30 -30
- package/docs/zh/guide/basic/publish-your-project.md +4 -4
- package/docs/zh/guide/basic/test-your-project.mdx +5 -3
- package/docs/zh/guide/basic/use-micro-generator.md +5 -5
- package/docs/zh/guide/basic/using-storybook.mdx +6 -4
- package/docs/zh/guide/best-practices/components.mdx +10 -10
- package/docs/zh/guide/intro/getting-started.md +2 -2
- package/docs/zh/index.md +1 -1
- package/docs/zh/plugins/guide/getting-started.mdx +3 -3
- package/docs/zh/plugins/guide/setup-function.mdx +2 -2
- package/modern.config.ts +4 -3
- package/package.json +3 -3
|
@@ -6,7 +6,7 @@ This chapter will describe how to develop component projects using the module en
|
|
|
6
6
|
|
|
7
7
|
<CH.Spotlight>
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```bash Interactive questions
|
|
10
10
|
npx @modern-js/create components-project
|
|
11
11
|
|
|
12
12
|
? Please select the solution you want to create Module Solution
|
|
@@ -14,11 +14,12 @@ npx @modern-js/create components-project
|
|
|
14
14
|
? Development Language TS
|
|
15
15
|
? Package Management Tool pnpm
|
|
16
16
|
```
|
|
17
|
+
|
|
17
18
|
---
|
|
18
19
|
|
|
19
20
|
It is recommended to use the `@modern-js/create` command to initialize an npm project.
|
|
20
21
|
|
|
21
|
-
```
|
|
22
|
+
```bash Interactive questions
|
|
22
23
|
npx @modern-js/create components-project
|
|
23
24
|
|
|
24
25
|
? Please select the solution you want to create Module Solution
|
|
@@ -31,7 +32,7 @@ npx @modern-js/create components-project
|
|
|
31
32
|
|
|
32
33
|
The initialized directory structure.
|
|
33
34
|
|
|
34
|
-
```
|
|
35
|
+
```bash The initialized directory structure
|
|
35
36
|
.
|
|
36
37
|
├── README.md
|
|
37
38
|
├── node_modules/
|
|
@@ -51,35 +52,36 @@ Modify the `. /src/index.ts` file suffix and content.
|
|
|
51
52
|
|
|
52
53
|
At this point, a component project is initialized.
|
|
53
54
|
|
|
54
|
-
```
|
|
55
|
+
```tsx ./src/index.tsx
|
|
55
56
|
export default () => {
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
);
|
|
59
|
-
}
|
|
57
|
+
return <div>hello world</div>;
|
|
58
|
+
};
|
|
60
59
|
```
|
|
60
|
+
|
|
61
61
|
</CH.Spotlight>
|
|
62
62
|
|
|
63
63
|
## Debugging code with Storybook
|
|
64
64
|
|
|
65
65
|
<CH.Spotlight>
|
|
66
66
|
|
|
67
|
-
```
|
|
67
|
+
```bash Terminal
|
|
68
68
|
pnpm run new
|
|
69
69
|
|
|
70
70
|
? Action Enable features
|
|
71
71
|
? Enable features Enable Visual Testing (Storybook)
|
|
72
72
|
```
|
|
73
|
+
|
|
73
74
|
---
|
|
74
75
|
|
|
75
76
|
Execute the `new` command in the project root directory to enable the Storybook feature.
|
|
76
77
|
|
|
77
|
-
```
|
|
78
|
+
```bash Terminal
|
|
78
79
|
pnpm run new
|
|
79
80
|
|
|
80
81
|
? Action Enable features
|
|
81
82
|
? Enable features Enable Visual Testing (Storybook)
|
|
82
83
|
```
|
|
84
|
+
|
|
83
85
|
---
|
|
84
86
|
|
|
85
87
|
Once successfully opened, you will see that a new dependency has been added to `package.json`. The `stories` directory and related initialization files are also created.
|
|
@@ -135,7 +137,7 @@ Such a configuration allows you to introduce code in Story code directly using t
|
|
|
135
137
|
|
|
136
138
|
<CH.Code>
|
|
137
139
|
|
|
138
|
-
```
|
|
140
|
+
```tsx ./stories/index.stories.tsx
|
|
139
141
|
import Component from 'components-demo';
|
|
140
142
|
|
|
141
143
|
export const YourStory = () => <Component />;
|
|
@@ -143,15 +145,14 @@ export const YourStory = () => <Component />;
|
|
|
143
145
|
export default {
|
|
144
146
|
title: 'Your Stories',
|
|
145
147
|
};
|
|
146
|
-
|
|
147
148
|
```
|
|
149
|
+
|
|
148
150
|
---
|
|
149
|
-
|
|
151
|
+
|
|
152
|
+
```tsx ./src/index.tsx
|
|
150
153
|
export default () => {
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
);
|
|
154
|
-
}
|
|
154
|
+
return <div>hello world</div>;
|
|
155
|
+
};
|
|
155
156
|
```
|
|
156
157
|
|
|
157
158
|
</CH.Code>
|
|
@@ -177,7 +178,7 @@ Debugging with source code has a limitation: some configurations are not equival
|
|
|
177
178
|
|
|
178
179
|
**This is why debugging with the product is recommended**.
|
|
179
180
|
|
|
180
|
-
```
|
|
181
|
+
```tsx ./stories/index.stories.tsx
|
|
181
182
|
import Component from '../src';
|
|
182
183
|
|
|
183
184
|
export const YourStory = () => <Component />;
|
|
@@ -195,30 +196,29 @@ Next we can add styles to the component.
|
|
|
195
196
|
|
|
196
197
|
The following capabilities are currently supported for developing styles.
|
|
197
198
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
- CSS/PostCSS
|
|
200
|
+
- Less
|
|
201
|
+
- Scss/Sass
|
|
202
|
+
- Tailwind CSS
|
|
203
|
+
- CSS Modules
|
|
203
204
|
|
|
204
205
|
### CSS/PostCSS
|
|
205
206
|
|
|
206
207
|
The module project supports PostCSS and has the following built-in postcss plugins.
|
|
207
208
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
- [flexbugs-fixes](https://github.com/luisrudge/postcss-flexbugs-fixes)
|
|
210
|
+
- [custom-properties](https://github.com/postcss/postcss-custom-properties)
|
|
211
|
+
- [initial](https://github.com/maximkoretskiy/postcss-initial)
|
|
212
|
+
- [page-break](https://github.com/shrpne/postcss-page-break)
|
|
213
|
+
- [font-variant](https://github.com/postcss/postcss-font-variant)
|
|
214
|
+
- [media-minmax](https://github.com/postcss/postcss-media-minmax)
|
|
215
|
+
- [nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting#readme)
|
|
215
216
|
|
|
216
217
|
So we can create `.css` files in our projects and use the syntax support and capabilities provided by these plugins directly in our css files.
|
|
217
218
|
|
|
218
219
|
<CH.Spotlight>
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
``` css ./src/index.css
|
|
221
|
+
```css ./src/index.css
|
|
222
222
|
a,
|
|
223
223
|
b {
|
|
224
224
|
color: red;
|
|
@@ -240,14 +240,15 @@ b {
|
|
|
240
240
|
|
|
241
241
|
Source Code.
|
|
242
242
|
|
|
243
|
-
```
|
|
243
|
+
```css ./src/index.css
|
|
244
|
+
|
|
244
245
|
```
|
|
245
246
|
|
|
246
247
|
---
|
|
247
248
|
|
|
248
249
|
css product.
|
|
249
250
|
|
|
250
|
-
```
|
|
251
|
+
```css ./dist/es/index.css
|
|
251
252
|
a,
|
|
252
253
|
b {
|
|
253
254
|
color: red;
|
|
@@ -283,11 +284,13 @@ div {
|
|
|
283
284
|
color: if(@bg-light, black, white);
|
|
284
285
|
}
|
|
285
286
|
```
|
|
287
|
+
|
|
286
288
|
---
|
|
287
289
|
|
|
288
290
|
Source Code.
|
|
289
291
|
|
|
290
292
|
```less ./src/common.less
|
|
293
|
+
|
|
291
294
|
```
|
|
292
295
|
|
|
293
296
|
---
|
|
@@ -320,11 +323,13 @@ body {
|
|
|
320
323
|
color: $primary-color;
|
|
321
324
|
}
|
|
322
325
|
```
|
|
326
|
+
|
|
323
327
|
---
|
|
324
328
|
|
|
325
329
|
源代码。
|
|
326
330
|
|
|
327
331
|
```sass ./src/common.sass
|
|
332
|
+
|
|
328
333
|
```
|
|
329
334
|
|
|
330
335
|
---
|
|
@@ -348,27 +353,29 @@ By default, this feature is not enabled in the module project, you need to enabl
|
|
|
348
353
|
|
|
349
354
|
<CH.Spotlight>
|
|
350
355
|
|
|
351
|
-
```
|
|
356
|
+
```bash Terminal
|
|
352
357
|
pnpm run new
|
|
353
358
|
|
|
354
359
|
? Action Enable features
|
|
355
360
|
? Enable features Enable Visual Testing (Storybook)
|
|
356
361
|
```
|
|
362
|
+
|
|
357
363
|
---
|
|
358
364
|
|
|
359
365
|
The Tailwind CSS feature can be enabled by executing the `new` command in the project root directory.
|
|
360
366
|
|
|
361
|
-
```
|
|
367
|
+
```bash Terminal
|
|
362
368
|
pnpm run new
|
|
363
369
|
|
|
364
370
|
? Action Enable features
|
|
365
371
|
? Enable features Enable Tailwind CSS
|
|
366
372
|
```
|
|
373
|
+
|
|
367
374
|
---
|
|
368
375
|
|
|
369
376
|
Once successfully opened, you will see that a new dependency has been added to `package.json`.
|
|
370
377
|
|
|
371
|
-
```
|
|
378
|
+
```json ./package.json
|
|
372
379
|
{
|
|
373
380
|
"devDependencies": {
|
|
374
381
|
"@modern-js/plugin-tailwindcss": "x.y.z"
|
|
@@ -384,26 +391,27 @@ Tailwind CSS offers two ways to use it.
|
|
|
384
391
|
|
|
385
392
|
<CH.Spotlight>
|
|
386
393
|
|
|
387
|
-
```
|
|
394
|
+
```tsx ./src/index.tsx
|
|
388
395
|
import 'tailwindcss/utilities.css';
|
|
389
396
|
|
|
390
397
|
export default () => {
|
|
391
|
-
return
|
|
392
|
-
|
|
393
|
-
);
|
|
394
|
-
}
|
|
398
|
+
return <div className="bg-black text-white">hello world</div>;
|
|
399
|
+
};
|
|
395
400
|
```
|
|
401
|
+
|
|
396
402
|
---
|
|
397
403
|
|
|
398
404
|
Tailwind CSS supports adding styles to HTML tags by using class names.
|
|
399
405
|
|
|
400
|
-
```
|
|
406
|
+
```tsx ./src/index.tsx focus=5:5
|
|
407
|
+
|
|
401
408
|
```
|
|
409
|
+
|
|
402
410
|
---
|
|
403
411
|
|
|
404
412
|
**When using HTML class names, be sure to import the Tailwind CSS equivalent css file. **
|
|
405
413
|
|
|
406
|
-
```
|
|
414
|
+
```tsx ./src/index.tsx focus=1:1
|
|
407
415
|
|
|
408
416
|
```
|
|
409
417
|
|
|
@@ -413,7 +421,6 @@ Style product.
|
|
|
413
421
|
|
|
414
422
|
> This is a bundle build.
|
|
415
423
|
|
|
416
|
-
|
|
417
424
|
```css ./dist/es/index.css
|
|
418
425
|
/* ../../node_modules/.pnpm/tailwindcss@2.2.19/node_modules/tailwindcss/utilities.css */
|
|
419
426
|
.table {
|
|
@@ -425,18 +432,20 @@ Style product.
|
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
434
|
@keyframes ping {
|
|
428
|
-
75%,
|
|
435
|
+
75%,
|
|
436
|
+
100% {
|
|
429
437
|
transform: scale(2);
|
|
430
438
|
opacity: 0;
|
|
431
439
|
}
|
|
432
440
|
}
|
|
433
441
|
@keyframes pulse {
|
|
434
442
|
50% {
|
|
435
|
-
opacity: .5;
|
|
443
|
+
opacity: 0.5;
|
|
436
444
|
}
|
|
437
445
|
}
|
|
438
446
|
@keyframes bounce {
|
|
439
|
-
0%,
|
|
447
|
+
0%,
|
|
448
|
+
100% {
|
|
440
449
|
transform: translateY(-25%);
|
|
441
450
|
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
|
|
442
451
|
}
|
|
@@ -456,17 +465,17 @@ Style product.
|
|
|
456
465
|
*,
|
|
457
466
|
::before,
|
|
458
467
|
::after {
|
|
459
|
-
--tw-shadow: 0 0 #0000
|
|
468
|
+
--tw-shadow: 0 0 #0000;
|
|
460
469
|
}
|
|
461
470
|
*,
|
|
462
471
|
::before,
|
|
463
472
|
::after {
|
|
464
|
-
--tw-ring-inset: var(--tw-empty
|
|
473
|
+
--tw-ring-inset: var(--tw-empty);
|
|
465
474
|
--tw-ring-offset-width: 0px;
|
|
466
475
|
--tw-ring-offset-color: #fff;
|
|
467
476
|
--tw-ring-color: rgba(59, 130, 246, 0.5);
|
|
468
477
|
--tw-ring-offset-shadow: 0 0 #0000;
|
|
469
|
-
--tw-ring-shadow: 0 0 #0000
|
|
478
|
+
--tw-ring-shadow: 0 0 #0000;
|
|
470
479
|
}
|
|
471
480
|
@media (min-width: 640px) {
|
|
472
481
|
}
|
|
@@ -478,10 +487,8 @@ Style product.
|
|
|
478
487
|
}
|
|
479
488
|
@media (min-width: 1536px) {
|
|
480
489
|
}
|
|
481
|
-
|
|
482
490
|
```
|
|
483
491
|
|
|
484
|
-
|
|
485
492
|
</CH.Spotlight>
|
|
486
493
|
|
|
487
494
|
#### `@apply`
|
|
@@ -490,7 +497,7 @@ Tailwind CSS provides the [`@apply`](https://v2.tailwindcss.com/docs/functions-a
|
|
|
490
497
|
|
|
491
498
|
`@apply` can be used in CSS, Less, and Sass.
|
|
492
499
|
|
|
493
|
-
```
|
|
500
|
+
```css
|
|
494
501
|
.btn {
|
|
495
502
|
@apply font-bold py-2 px-4 rounded;
|
|
496
503
|
}
|
|
@@ -504,22 +511,25 @@ When using Tailwind with Sass, the presence of `!important` after `@apply` requi
|
|
|
504
511
|
|
|
505
512
|
<CH.Spotlight>
|
|
506
513
|
|
|
507
|
-
```
|
|
514
|
+
```sass
|
|
508
515
|
.alert {
|
|
509
516
|
@apply bg-red-500 !important;
|
|
510
517
|
}
|
|
511
518
|
```
|
|
519
|
+
|
|
512
520
|
---
|
|
513
521
|
|
|
514
522
|
It does not work properly.
|
|
515
523
|
|
|
516
|
-
```
|
|
524
|
+
```sass
|
|
525
|
+
|
|
517
526
|
```
|
|
527
|
+
|
|
518
528
|
---
|
|
519
529
|
|
|
520
530
|
Can work properly.
|
|
521
531
|
|
|
522
|
-
```
|
|
532
|
+
```sass
|
|
523
533
|
.alert {
|
|
524
534
|
@apply bg-red-500 #{!important};
|
|
525
535
|
}
|
|
@@ -533,7 +543,7 @@ When using Tailwind with Less, you cannot nest Tailwind's `@screen` directive.
|
|
|
533
543
|
|
|
534
544
|
<CH.Spotlight>
|
|
535
545
|
|
|
536
|
-
```
|
|
546
|
+
```less
|
|
537
547
|
.card {
|
|
538
548
|
@apply rounded-none;
|
|
539
549
|
|
|
@@ -542,19 +552,22 @@ When using Tailwind with Less, you cannot nest Tailwind's `@screen` directive.
|
|
|
542
552
|
}
|
|
543
553
|
}
|
|
544
554
|
```
|
|
555
|
+
|
|
545
556
|
---
|
|
546
557
|
|
|
547
558
|
It does not work properly.
|
|
548
559
|
|
|
549
|
-
```
|
|
560
|
+
```less
|
|
561
|
+
|
|
550
562
|
```
|
|
563
|
+
|
|
551
564
|
---
|
|
552
565
|
|
|
553
566
|
Instead, use regular media queries and the `theme()` function to reference your screen size, or simply don't nest your `@screen` directive.
|
|
554
567
|
|
|
555
568
|
<CH.Code>
|
|
556
569
|
|
|
557
|
-
```
|
|
570
|
+
```less Method One
|
|
558
571
|
// Use a regular media query and theme()
|
|
559
572
|
.card {
|
|
560
573
|
@apply rounded-none;
|
|
@@ -567,7 +580,7 @@ Instead, use regular media queries and the `theme()` function to reference your
|
|
|
567
580
|
|
|
568
581
|
---
|
|
569
582
|
|
|
570
|
-
```
|
|
583
|
+
```less Method Two
|
|
571
584
|
// Use the @screen directive at the top-level
|
|
572
585
|
.card {
|
|
573
586
|
@apply rounded-none;
|
|
@@ -594,22 +607,19 @@ For the following code, there is a big difference between the bundle and bundlel
|
|
|
594
607
|
|
|
595
608
|
> The so-called bundle and bundleless can be found in [[Bundle and Bundleless]](/en/guide/advance/in-depth-about-build#bundle- and-bundleless)
|
|
596
609
|
|
|
597
|
-
|
|
598
|
-
``` tsx ./src/index.tsx
|
|
610
|
+
```tsx ./src/index.tsx
|
|
599
611
|
import 'tailwindcss/utilities.css';
|
|
600
612
|
|
|
601
613
|
export default () => {
|
|
602
|
-
return
|
|
603
|
-
|
|
604
|
-
);
|
|
605
|
-
}
|
|
614
|
+
return <div className="bg-black text-white">hello world11</div>;
|
|
615
|
+
};
|
|
606
616
|
```
|
|
607
617
|
|
|
608
618
|
In Bundle mode, third-party dependencies are packaged in.
|
|
609
619
|
|
|
610
620
|
For styles, a separate product file is generated, and there is no code related to importing styles in the Js product file.
|
|
611
621
|
|
|
612
|
-
If you need to inject styles into Js products, you can enable the [`style.inject` API](/en/api/build-config#inject).
|
|
622
|
+
If you need to inject styles into Js products, you can enable the [`style.inject` API](/en/api/config/build-config#inject).
|
|
613
623
|
|
|
614
624
|
<CH.Code>
|
|
615
625
|
```css ./dist/es/index.css
|
|
@@ -696,52 +706,49 @@ export {
|
|
|
696
706
|
In Bundleless mode, no third-party dependencies are packaged in, and no style products are generated at this time.
|
|
697
707
|
|
|
698
708
|
```js ./dist/es/index.js
|
|
699
|
-
import { jsx } from
|
|
700
|
-
import
|
|
709
|
+
import { jsx } from 'react/jsx-runtime';
|
|
710
|
+
import 'tailwindcss/utilities.css';
|
|
701
711
|
var src_default = () => {
|
|
702
|
-
return /* @__PURE__ */ jsx(
|
|
703
|
-
className:
|
|
704
|
-
children:
|
|
712
|
+
return /* @__PURE__ */ jsx('div', {
|
|
713
|
+
className: 'bg-black text-white',
|
|
714
|
+
children: 'hello world11',
|
|
705
715
|
});
|
|
706
716
|
};
|
|
707
|
-
export {
|
|
708
|
-
src_default as default
|
|
709
|
-
};
|
|
717
|
+
export { src_default as default };
|
|
710
718
|
```
|
|
711
719
|
|
|
712
720
|
### CSS Modules
|
|
713
721
|
|
|
714
722
|
Module projects support the development of styles using CSS Modules. By default, the following files are recognized as CSS Module files.
|
|
715
723
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
724
|
+
- `.module.css`
|
|
725
|
+
- `.module.less`
|
|
726
|
+
- `.module.scss`
|
|
727
|
+
- `.module.sass`
|
|
720
728
|
|
|
721
729
|
If you need to configure CSS Modules, you can check out the API at
|
|
722
730
|
|
|
723
|
-
|
|
724
|
-
|
|
731
|
+
- [autoModules](en/api/config/build-config#automodules)
|
|
732
|
+
- [modules](/en/api/config/build-config#modules)
|
|
725
733
|
|
|
726
734
|
The following is a code example.
|
|
727
735
|
|
|
728
736
|
<CH.Code>
|
|
729
737
|
|
|
730
|
-
```
|
|
738
|
+
```tsx ./src/index.tsx
|
|
731
739
|
import style from './index.module.css';
|
|
732
740
|
|
|
733
741
|
export default () => {
|
|
734
|
-
return
|
|
735
|
-
|
|
736
|
-
);
|
|
737
|
-
}
|
|
742
|
+
return <div className={style.btn}>hello world</div>;
|
|
743
|
+
};
|
|
738
744
|
```
|
|
739
745
|
|
|
740
|
-
```
|
|
746
|
+
```css ./src/index.module.css
|
|
741
747
|
.btn {
|
|
742
748
|
color: blue;
|
|
743
749
|
}
|
|
744
750
|
```
|
|
751
|
+
|
|
745
752
|
</CH.Code>
|
|
746
753
|
|
|
747
754
|
## Configuring build products
|
|
@@ -756,28 +763,27 @@ Based on most scenarios of component project usage, **it is recommended to use t
|
|
|
756
763
|
│ └── types
|
|
757
764
|
```
|
|
758
765
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
766
|
+
- `. /dist/es`: Contains bundleless products in ES modules format that support the es6 syntax.
|
|
767
|
+
- `. /dist/lib`: Contains bundleless products in CommonJS format with support for es6 syntax.
|
|
768
|
+
- `. /dist/types`: Contains the types file.
|
|
762
769
|
|
|
763
|
-
The [`buildPreset`](/en/api/build-preset) can be configured manually if there is a requirement to use syntax support, and supports modifying the supported syntax by adding a suffix to `npm-component`.
|
|
770
|
+
The [`buildPreset`](/en/api/config/build-preset) can be configured manually if there is a requirement to use syntax support, and supports modifying the supported syntax by adding a suffix to `npm-component`.
|
|
764
771
|
|
|
765
|
-
```
|
|
772
|
+
```tsx
|
|
766
773
|
export default defineConfig({
|
|
767
774
|
buildPreset: 'npm-component-es2019',
|
|
768
775
|
});
|
|
769
776
|
```
|
|
770
777
|
|
|
771
|
-
If you have special needs for the build product directory structure, you can use the [`buildConfig` API](/en/api/build-config), which can be used by the following documentation.
|
|
778
|
+
If you have special needs for the build product directory structure, you can use the [`buildConfig` API](/en/api/config/build-config), which can be used by the following documentation.
|
|
772
779
|
|
|
773
|
-
|
|
774
|
-
|
|
780
|
+
- [modify-output-product](/en/guide/basic/modify-output-product#build-configuration-object)
|
|
781
|
+
- [in-depth-about-build](/en/guide/advance/in-depth-about-build)
|
|
775
782
|
|
|
776
783
|
## Testing components
|
|
777
784
|
|
|
778
785
|
For more information on how to test components, please refer to [[Test project]](/en/guide/basic/test-your-project).
|
|
779
786
|
|
|
780
|
-
|
|
781
787
|
## Releasing components
|
|
782
788
|
|
|
783
789
|
It is recommended to use module project to provide version publishing function, you can refer to [[Versioning and publishing]](/en/guide/basic/publish-your-project).
|
|
@@ -78,6 +78,6 @@ We can start the project build directly with the `pnpm build` command, and start
|
|
|
78
78
|
|
|
79
79
|
Choose your tutorial scenario...
|
|
80
80
|
|
|
81
|
-
- I'm a beginner and need to learn [basic usage](/en/guide/before-getting-started) of Module Tools.
|
|
82
|
-
- I have learned the basic usage of Module Tools and can learn [advanced usage](/en/guide/before-getting-started) of Module Tools.
|
|
81
|
+
- I'm a beginner and need to learn [basic usage](/en/guide/basic/before-getting-started) of Module Tools.
|
|
82
|
+
- I have learned the basic usage of Module Tools and can learn [advanced usage](/en/guide/basic/before-getting-started) of Module Tools.
|
|
83
83
|
- I am the maintainer of the project and need to learn how to develop plugins for Module Tools and learn more about Module Tools Advanced.
|
package/docs/en/index.md
CHANGED
|
@@ -2,32 +2,29 @@
|
|
|
2
2
|
pageType: home
|
|
3
3
|
|
|
4
4
|
hero:
|
|
5
|
-
name:
|
|
6
|
-
text:
|
|
7
|
-
tagline:
|
|
5
|
+
name: Module Tools
|
|
6
|
+
text: Module engineering solutions
|
|
7
|
+
tagline: simple, powerful, high-performance modern npm package development solution
|
|
8
8
|
actions:
|
|
9
9
|
- theme: brand
|
|
10
|
-
text:
|
|
11
|
-
link: /guide/
|
|
10
|
+
text: welcome
|
|
11
|
+
link: /guide/intro/welcome
|
|
12
12
|
|
|
13
13
|
features:
|
|
14
|
-
- title: '
|
|
15
|
-
details:
|
|
14
|
+
- title: 'Esbuild: The High Performance JS Bundler'
|
|
15
|
+
details: Built on Esbuild, the build is extremely fast and gives you the ultimate development experience.
|
|
16
16
|
icon: 🚀
|
|
17
|
-
- title: 'Storybook:
|
|
18
|
-
details:
|
|
17
|
+
- title: 'Storybook: The community popular UI development tool'
|
|
18
|
+
details: Integrated with Storybook, you can use it to debug UI.
|
|
19
19
|
icon: 📦
|
|
20
|
-
- title: 'Island: 强大的现代化SSG方案'
|
|
21
|
-
details: 高性能的静态站点生成器。
|
|
22
|
-
icon: 🔑
|
|
23
20
|
- title: 'transform + bundle'
|
|
24
|
-
details:
|
|
21
|
+
details: Both bundle and bundleless build modes are supported.
|
|
25
22
|
icon: ✨
|
|
26
|
-
- title: '
|
|
27
|
-
details:
|
|
23
|
+
- title: 'zero configuration'
|
|
24
|
+
details: Develop your npm packages without any configuration, with built-in presets covering multiple scenarios.
|
|
28
25
|
icon: 🛠️
|
|
29
|
-
- title: '
|
|
30
|
-
details:
|
|
26
|
+
- title: 'Extensible: Provides a powerful plugin mechanism'
|
|
27
|
+
details: With its plugin extension mechanism, you can easily extend the capabilities of Module Tools.
|
|
31
28
|
icon: 🎨
|
|
32
29
|
---
|
|
33
30
|
# index
|
|
@@ -51,7 +51,7 @@ export const ExamplePlugin = (): CliPlugin<ModuleTools> => {
|
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
-
Then we register the plugin we just wrote via the [`plugins`](/en/api/plugins) API.
|
|
54
|
+
Then we register the plugin we just wrote via the [`plugins`](/en/api/config/plugins) API.
|
|
55
55
|
|
|
56
56
|
```ts . /modern.config.ts
|
|
57
57
|
import { ExamplePlugin } from '. /plugins/example';
|
|
@@ -81,4 +81,4 @@ With the above example, we learned the following things.
|
|
|
81
81
|
In addition to the above, we also need to understand.
|
|
82
82
|
|
|
83
83
|
- [plugin objects, type definitions and recommended configuration items](/en/plugins/guide/plugin-object)
|
|
84
|
-
- [setup functions, `api` object parameters, lifecycle hooks](/en/plugins/guide/setup-
|
|
84
|
+
- [setup functions, `api` object parameters, lifecycle hooks](/en/plugins/guide/setup-function)
|
|
@@ -4,7 +4,7 @@ sidebar_position: 3
|
|
|
4
4
|
|
|
5
5
|
# Setup function
|
|
6
6
|
|
|
7
|
-
In the [[Plugin object]](/
|
|
7
|
+
In the [[Plugin object]](/plugins/guide/plugin-object) section we know that the plug-in object contains a `setup` function that not only contains an `api` object parameter, but also returns a Hooks object.
|
|
8
8
|
|
|
9
9
|
## Plugin API objects
|
|
10
10
|
|
|
@@ -114,4 +114,4 @@ Currently there are two main types of hooks.
|
|
|
114
114
|
- `buildPlatform` hook: triggered only when the `build --platform` command is executed to generate other build products.
|
|
115
115
|
- debug hooks: hooks that are triggered when running the `dev` command.
|
|
116
116
|
|
|
117
|
-
See the [API documentation](/en/api/plugin-hooks) for a full list of lifecycle hooks.
|
|
117
|
+
See the [API documentation](/en/api/plugin-api/plugin-hooks) for a full list of lifecycle hooks.
|