@modern-js/main-doc 2.31.2 → 2.32.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.
- package/CHANGELOG.md +13 -0
- package/LICENSE +1 -1
- package/docs/en/components/enable-bff-caution.mdx +1 -1
- package/docs/en/configure/app/auto-load-plugin.mdx +2 -2
- package/docs/en/configure/app/bff/_category_.json +1 -1
- package/docs/en/configure/app/builder-plugins.mdx +2 -2
- package/docs/en/configure/app/dev/_category_.json +1 -1
- package/docs/en/configure/app/experiments/_category_.json +1 -1
- package/docs/en/configure/app/html/_category_.json +1 -1
- package/docs/en/configure/app/output/_category_.json +1 -1
- package/docs/en/configure/app/output/ssg.mdx +1 -1
- package/docs/en/configure/app/plugins.mdx +0 -1
- package/docs/en/configure/app/runtime/_category_.json +1 -1
- package/docs/en/configure/app/security/_category_.json +1 -1
- package/docs/en/configure/app/server/_category_.json +1 -1
- package/docs/en/configure/app/source/_category_.json +1 -1
- package/docs/en/configure/app/source/design-system.mdx +4 -4
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/mainEntryName.mdx +1 -1
- package/docs/en/configure/app/testing/_category_.json +1 -1
- package/docs/en/configure/app/tools/_category_.json +1 -1
- package/docs/en/configure/app/tools/tailwindcss.mdx +5 -12
- package/docs/en/configure/app/usage.mdx +1 -3
- package/docs/en/guides/advanced-features/bff/_category_.json +1 -1
- package/docs/en/guides/advanced-features/code-split.mdx +2 -2
- package/docs/en/guides/advanced-features/eslint.mdx +2 -2
- package/docs/en/guides/advanced-features/low-level.mdx +2 -2
- package/docs/en/guides/advanced-features/ssg.mdx +2 -3
- package/docs/en/guides/advanced-features/ssr.mdx +2 -3
- package/docs/en/guides/advanced-features/testing.mdx +3 -3
- package/docs/en/guides/advanced-features/using-storybook.mdx +1 -1
- package/docs/en/guides/advanced-features/web-server.mdx +2 -2
- package/docs/en/guides/basic-features/alias.mdx +3 -3
- package/docs/en/guides/basic-features/css.mdx +33 -38
- package/docs/en/guides/basic-features/data-fetch.mdx +2 -2
- package/docs/en/guides/basic-features/env-vars.mdx +2 -2
- package/docs/en/guides/basic-features/html.mdx +0 -1
- package/docs/en/guides/basic-features/mock.mdx +3 -3
- package/docs/en/guides/basic-features/proxy.mdx +3 -3
- package/docs/en/guides/basic-features/routes.mdx +1 -2
- package/docs/en/guides/concept/builder.mdx +2 -2
- package/docs/en/guides/concept/entries.mdx +1 -1
- package/docs/en/guides/get-started/upgrade.mdx +1 -2
- package/docs/zh/community/releases.mdx +1 -1
- package/docs/zh/community/team.mdx +1 -1
- package/docs/zh/components/enable-bff-caution.mdx +2 -2
- package/docs/zh/configure/app/auto-load-plugin.mdx +2 -3
- package/docs/zh/configure/app/bff/_category_.json +2 -2
- package/docs/zh/configure/app/builder-plugins.mdx +2 -3
- package/docs/zh/configure/app/deploy/_category_.json +1 -1
- package/docs/zh/configure/app/dev/_category_.json +2 -2
- package/docs/zh/configure/app/experiments/_category_.json +2 -2
- package/docs/zh/configure/app/html/_category_.json +2 -2
- package/docs/zh/configure/app/output/_category_.json +2 -2
- package/docs/zh/configure/app/output/ssg.mdx +1 -1
- package/docs/zh/configure/app/performance/_category_.json +1 -1
- package/docs/zh/configure/app/plugins.mdx +1 -2
- package/docs/zh/configure/app/runtime/_category_.json +2 -2
- package/docs/zh/configure/app/security/_category_.json +2 -2
- package/docs/zh/configure/app/server/_category_.json +2 -2
- package/docs/zh/configure/app/source/_category_.json +2 -2
- package/docs/zh/configure/app/source/design-system.mdx +1 -1
- package/docs/zh/configure/app/testing/_category_.json +2 -2
- package/docs/zh/configure/app/tools/_category_.json +2 -2
- package/docs/zh/configure/app/tools/tailwindcss.mdx +6 -13
- package/docs/zh/configure/app/usage.mdx +1 -3
- package/docs/zh/guides/advanced-features/bff/_category_.json +1 -1
- package/docs/zh/guides/advanced-features/code-split.mdx +2 -2
- package/docs/zh/guides/advanced-features/compatibility.mdx +1 -1
- package/docs/zh/guides/advanced-features/eslint.mdx +1 -1
- package/docs/zh/guides/advanced-features/low-level.mdx +2 -2
- package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -1
- package/docs/zh/guides/advanced-features/ssg.mdx +3 -4
- package/docs/zh/guides/advanced-features/ssr.mdx +2 -3
- package/docs/zh/guides/advanced-features/testing.mdx +2 -2
- package/docs/zh/guides/advanced-features/using-storybook.mdx +1 -1
- package/docs/zh/guides/advanced-features/web-server.mdx +2 -2
- package/docs/zh/guides/basic-features/alias.mdx +3 -3
- package/docs/zh/guides/basic-features/css.mdx +34 -38
- package/docs/zh/guides/basic-features/data-fetch.mdx +1 -2
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/mock.mdx +2 -2
- package/docs/zh/guides/basic-features/proxy.mdx +3 -3
- package/docs/zh/guides/basic-features/routes.mdx +1 -2
- package/docs/zh/guides/concept/builder.mdx +1 -1
- package/docs/zh/guides/concept/entries.mdx +3 -3
- package/docs/zh/guides/get-started/upgrade.mdx +1 -2
- package/package.json +5 -5
- package/src/i18n/enUS.ts +1 -1
- package/src/i18n/zhCN.ts +1 -1
|
@@ -10,21 +10,14 @@ sidebar_label: tailwindcss
|
|
|
10
10
|
```js
|
|
11
11
|
const tailwind = {
|
|
12
12
|
content: [
|
|
13
|
-
'./
|
|
14
|
-
'./config/html/**/*.ejs',
|
|
15
|
-
'./config/html/**/*.hbs',
|
|
16
|
-
'./src/**/*.js',
|
|
17
|
-
'./src/**/*.jsx',
|
|
18
|
-
'./src/**/*.ts',
|
|
19
|
-
'./src/**/*.tsx',
|
|
13
|
+
'./src/**/*.{js,jsx,ts,tsx}',
|
|
14
|
+
'./config/html/**/*.{html,ejs,hbs}',
|
|
20
15
|
'./storybook/**/*',
|
|
21
16
|
],
|
|
22
|
-
// 使用 source.designSystem 配置作为 Tailwind CSS Theme 配置
|
|
23
|
-
theme: source.designSystem,
|
|
24
17
|
};
|
|
25
18
|
```
|
|
26
19
|
|
|
27
|
-
对应 [
|
|
20
|
+
对应 [Tailwind CSS](https://tailwindcss.com/docs/configuration) 的配置。
|
|
28
21
|
|
|
29
22
|
### Function 类型
|
|
30
23
|
|
|
@@ -58,8 +51,8 @@ export default {
|
|
|
58
51
|
};
|
|
59
52
|
```
|
|
60
53
|
|
|
61
|
-
###
|
|
54
|
+
### 注意事项
|
|
62
55
|
|
|
63
|
-
|
|
56
|
+
注意,如果你同时使用了 [source.designSystem](/configure/app/source/design-system) 配置项,那么 Tailwind CSS 的 `theme` 配置将会被 `source.designSystem` 的值所覆盖。
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
其他配置的使用方式与 Tailwind CSS 官方用法一致,请参考 [tailwindcss - Configuration](https://tailwindcss.com/docs/configuration)。
|
|
@@ -203,9 +203,7 @@ export default defineConfig({
|
|
|
203
203
|
- 由于 `modern.config.local.ts` 仅在本地调试时使用,因此不建议将其提交到代码仓库中,请确保项目的 `.gitignore` 文件中包含 `modern.config.local.ts` 等文件。
|
|
204
204
|
|
|
205
205
|
```bash title=".gitingore"
|
|
206
|
-
modern.config.local
|
|
207
|
-
modern.config.local.js
|
|
208
|
-
modern.config.local.mjs
|
|
206
|
+
modern.config.local.*
|
|
209
207
|
```
|
|
210
208
|
|
|
211
209
|
## 合并多份配置
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
sidebar_position: 4
|
|
2
|
+
sidebar_position: 5
|
|
4
3
|
---
|
|
5
4
|
|
|
6
|
-
#
|
|
5
|
+
# 静态站点生成
|
|
7
6
|
|
|
8
7
|
SSG(Static Site Generation)是一种基于数据与模板,在构建时渲染完整静态网页的技术解决方案。
|
|
9
8
|
|
|
@@ -55,7 +54,7 @@ SSG 在**约定式路由**和**自控式路由**下的使用方式不同。
|
|
|
55
54
|
- `/user/profile`
|
|
56
55
|
|
|
57
56
|
:::note
|
|
58
|
-
如果还不了解约定式路由的规则,可以先查看[
|
|
57
|
+
如果还不了解约定式路由的规则,可以先查看[路由方案](/guides/basic-features/routes)。
|
|
59
58
|
|
|
60
59
|
:::
|
|
61
60
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
sidebar_position: 2
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# 样式开发
|
|
6
6
|
|
|
7
7
|
Modern.js 内置多种常用的 CSS 开发方案,包括 Less / Sass / Stylus 预处理器、PostCSS、CSS Modules、CSS-in-JS 和 Tailwind CSS。
|
|
8
8
|
|
|
@@ -65,7 +65,7 @@ Modern.js 内部集成了 Babel 的 [babel-plugin-styled-components](https://git
|
|
|
65
65
|
|
|
66
66
|
按照如下进行选择:
|
|
67
67
|
|
|
68
|
-
```
|
|
68
|
+
```text
|
|
69
69
|
? 请选择你想要的操作 启用可选功能
|
|
70
70
|
? 请选择功能名称 启用 「Tailwind CSS」 支持
|
|
71
71
|
```
|
|
@@ -103,6 +103,38 @@ const App = () => (
|
|
|
103
103
|
|
|
104
104
|
:::
|
|
105
105
|
|
|
106
|
+
### Tailwind CSS 自动补全
|
|
107
|
+
|
|
108
|
+
Tailwind CSS 官方提供了 [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) 插件,用于在 VS Code 中自动补全 Tailwind CSS 的 class names、CSS functions 和 directives。
|
|
109
|
+
|
|
110
|
+
你可以参考以下步骤来启动自动补全功能:
|
|
111
|
+
|
|
112
|
+
1. 在 VS Code 中安装 [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) 插件。
|
|
113
|
+
2. 在项目的根目录创建 `tailwind.config.ts` 文件,并写入你需要的 Tailwind CSS 配置。
|
|
114
|
+
|
|
115
|
+
```ts title="tailwind.config.ts"
|
|
116
|
+
export default {
|
|
117
|
+
content: [
|
|
118
|
+
'./src/**/*.{js,jsx,ts,tsx}',
|
|
119
|
+
'./config/html/**/*.{html,ejs,hbs}',
|
|
120
|
+
'./storybook/**/*',
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
3. 在 `modern.config.ts` 中通过 [tools.tailwindcss](/configure/app/tools/tailwindcss) 引用你创建的 `tailwind.config.ts` 文件,使 Modern.js 可以正确识别 Tailwind CSS 配置内容。
|
|
126
|
+
|
|
127
|
+
```ts title="modern.config.ts"
|
|
128
|
+
import tailwindConfig from './tailwind.config';
|
|
129
|
+
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
tools: {
|
|
132
|
+
tailwindcss: tailwindConfig,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
|
|
106
138
|
### Tailwind CSS 版本
|
|
107
139
|
|
|
108
140
|
Modern.js 同时支持 Tailwind CSS v2 和 v3 版本,框架会识别项目 `package.json` 中的 `tailwindcss` 依赖版本,并启用相应的配置。默认情况下,我们会为你安装 Tailwind CSS v3 版本。
|
|
@@ -120,39 +152,3 @@ Tailwind CSS v2 和 v3 均不支持 IE 11 浏览器,相关背景请参考:
|
|
|
120
152
|
- [Tailwind CSS v2 - Browser Support](https://v2.tailwindcss.com/docs/browser-support)
|
|
121
153
|
|
|
122
154
|
如果你在 IE 11 浏览器上使用 Tailwind CSS,可能会出现部分样式不可用的现象,请谨慎使用。
|
|
123
|
-
|
|
124
|
-
### Theme 配置
|
|
125
|
-
|
|
126
|
-
当需要自定义 Tailwind CSS 的 [theme](https://tailwindcss.com/docs/theme) 配置的时候,可以在配置 [`source.designSystem`](/configure/app/source/design-system) 中修改,例如,颜色主题中增加一个 `primary`:
|
|
127
|
-
|
|
128
|
-
```ts title="modern.config.ts"
|
|
129
|
-
export default defineConfig({
|
|
130
|
-
source: {
|
|
131
|
-
designSystem: {
|
|
132
|
-
extend: {
|
|
133
|
-
colors: {
|
|
134
|
-
primary: '#5c6ac4',
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
当需要对 Tailwind CSS 做 [theme](https://tailwindcss.com/docs/theme) 以外的其他特殊配置时,可以在 [`tools.tailwindcss`](/configure/app/tools/tailwindcss) 中配置,例如设置 `variants`:
|
|
143
|
-
|
|
144
|
-
```ts title="modern.config.ts"
|
|
145
|
-
export default defineConfig({
|
|
146
|
-
tools: {
|
|
147
|
-
tailwindcss: {
|
|
148
|
-
variants: {
|
|
149
|
-
extend: {
|
|
150
|
-
backgroundColor: ['active'],
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
> 当你为项目配置 Tailwind CSS 的时候,[source.designSystem](/configure/app/source/design-system) 和 [tools.tailwindcss](/configure/app/tools/tailwindcss) 这两个配置的组合等价于单独配置了一个 `tailwindcss.config.js` 文件。其中 [source.designSystem](/configure/app/source/design-system) 等效于 Tailwind CSS 的 [theme](https://v2.tailwindcss.com/docs/configuration#theme) 配置。
|
|
@@ -16,7 +16,7 @@ Modern.js Builder 是 Modern.js 体系的核心组件之一,它是一个面向
|
|
|
16
16
|
- 通用构建引擎:Modern.js Builder。
|
|
17
17
|
- 底层打包工具:webpack 和 Rspack。
|
|
18
18
|
|
|
19
|
-
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-
|
|
19
|
+
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-0824.png" style={{ width: '100%', maxWidth: '540px' }} />
|
|
20
20
|
|
|
21
21
|
## 构建文档
|
|
22
22
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
sidebar_position: 1
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# 页面入口
|
|
6
6
|
|
|
7
7
|
通过本章节,你可以了解到 Modern.js 中的入口约定,以及如何自定义入口。
|
|
8
8
|
|
|
@@ -114,7 +114,7 @@ import EntryMode from '@site-docs/components/entry-mode.mdx';
|
|
|
114
114
|
|
|
115
115
|
上述目录中,`layout.tsx` 中导出的组件会作为最外层的组件,`page.tsx` 中导出的组件会作为 `/` 路由的组件。
|
|
116
116
|
|
|
117
|
-
详细内容可以参考[
|
|
117
|
+
详细内容可以参考[路由方案](/guides/basic-features/routes#约定式路由)。
|
|
118
118
|
|
|
119
119
|
#### 自控式路由
|
|
120
120
|
|
|
@@ -135,7 +135,7 @@ export default () => {
|
|
|
135
135
|
};
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
详细内容可以参考[
|
|
138
|
+
详细内容可以参考[路由方案](/guides/basic-features/routes#自控式路由)。
|
|
139
139
|
|
|
140
140
|
#### 自定义 Bootstrap
|
|
141
141
|
|
package/package.json
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.32.1",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public",
|
|
22
22
|
"provenance": true
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@modern-js/builder-doc": "^2.
|
|
25
|
+
"@modern-js/builder-doc": "^2.32.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"classnames": "^2",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"fs-extra": "^10",
|
|
35
35
|
"@types/node": "^16",
|
|
36
36
|
"@types/fs-extra": "^9",
|
|
37
|
-
"@modern-js/builder-doc": "2.
|
|
38
|
-
"@modern-js/doc-tools": "2.
|
|
39
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.
|
|
37
|
+
"@modern-js/builder-doc": "2.32.1",
|
|
38
|
+
"@modern-js/doc-tools": "2.32.1",
|
|
39
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.32.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "modern dev",
|
package/src/i18n/enUS.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const EN_US = {
|
|
|
18
18
|
feature4: 'Multi-Rendering Mode',
|
|
19
19
|
featureDesc4: 'SSR, SSG, SPR, all out of the box for you.',
|
|
20
20
|
feature5: 'CSS Solutions',
|
|
21
|
-
featureDesc5: 'CSS Modules, CSS-in-JS,
|
|
21
|
+
featureDesc5: 'CSS Modules, CSS-in-JS, Tailwind CSS, take your pick.',
|
|
22
22
|
feature6: 'Easy to Configure',
|
|
23
23
|
featureDesc6:
|
|
24
24
|
'Launch with zero configuration, then everything is configurable.',
|
package/src/i18n/zhCN.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const ZH_CN: Record<keyof typeof EN_US, string> = {
|
|
|
19
19
|
feature4: '多渲染模式',
|
|
20
20
|
featureDesc4: 'SSR、SSG、SPR 等多种渲染模式,通通开箱即用。',
|
|
21
21
|
feature5: 'CSS 方案',
|
|
22
|
-
featureDesc5: 'CSS Modules、CSS-in-JS、
|
|
22
|
+
featureDesc5: 'CSS Modules、CSS-in-JS、Tailwind CSS,任你挑选。',
|
|
23
23
|
feature6: '易于配置',
|
|
24
24
|
featureDesc6: '以零配置启动,然后一切皆可配置。',
|
|
25
25
|
|