@modern-js/main-doc 0.0.0-nightly-20241207170715 → 0.0.0-nightly-20241209170723
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/docs/en/configure/app/tools/lightningcss-loader.mdx +41 -0
- package/docs/en/configure/app/tools/postcss.mdx +5 -3
- package/docs/en/guides/basic-features/css/css.mdx +6 -0
- package/docs/en/guides/get-started/tech-stack.mdx +2 -0
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +41 -0
- package/docs/zh/configure/app/tools/postcss.mdx +2 -0
- package/docs/zh/guides/basic-features/css/css.mdx +6 -0
- package/docs/zh/guides/get-started/tech-stack.mdx +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: lightningcssLoader
|
|
3
|
+
configName: tools.lightningcssLoader
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# tools.lightningcssLoader
|
|
7
|
+
|
|
8
|
+
- **Type:** `Rspack.LightningcssLoaderOptions | Function | boolean`
|
|
9
|
+
- **Default:** `Rspack.LightningcssLoaderOptions | Function | boolean`
|
|
10
|
+
- **Bundler:** `only support rspack`
|
|
11
|
+
|
|
12
|
+
You can configure [builtin:lightningcss-loader](https://rspack.dev/guide/features/builtin-lightningcss-loader) through `tools.lightningcssLoader`.
|
|
13
|
+
|
|
14
|
+
## Enable loader
|
|
15
|
+
|
|
16
|
+
Set `tools.lightningcssLoader` to `true` to enable Rsbuild's built-in `lightningcss-loader`:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default {
|
|
20
|
+
tools: {
|
|
21
|
+
lightningcssLoader: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
At this time, the default configuration is as follows:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const defaultOptions = {
|
|
30
|
+
// use current browserslist config
|
|
31
|
+
targets: browserslist,
|
|
32
|
+
// minify is enabled when output.injectStyles is true and in production mode
|
|
33
|
+
minify: config.mode === 'production' && config.output.injectStyles,
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It should be noted that when `lightningcss-loader` is turned on, `postcss-loader` will be turned off by default.
|
|
38
|
+
|
|
39
|
+
import RsbuildConig from '@site-docs/components/rsbuild-config-tooltip';
|
|
40
|
+
|
|
41
|
+
<RsbuildConig />
|
|
@@ -12,26 +12,28 @@ configName: tools.postcss
|
|
|
12
12
|
const defaultOptions = {
|
|
13
13
|
postcssOptions: {
|
|
14
14
|
plugins: [
|
|
15
|
-
//
|
|
15
|
+
// The following plugins are enabled by default
|
|
16
16
|
require('postcss-nesting'),
|
|
17
17
|
require('postcss-media-minmax'),
|
|
18
18
|
require('postcss-flexbugs-fixes'),
|
|
19
19
|
require('autoprefixer')({
|
|
20
20
|
flexbox: 'no-2009',
|
|
21
21
|
}),
|
|
22
|
-
//
|
|
22
|
+
// The following plugins are only enabled when compatible with legacy browsers
|
|
23
23
|
require('postcss-custom-properties'),
|
|
24
24
|
require('postcss-initial'),
|
|
25
25
|
require('postcss-page-break'),
|
|
26
26
|
require('postcss-font-variant'),
|
|
27
27
|
],
|
|
28
|
-
// 默认在开发环境下启用 CSS 的 Source Map
|
|
29
28
|
sourceMap: isDev,
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
```
|
|
32
|
+
|
|
33
33
|
Modern.js integrates PostCSS by default, you can configure [postcss-loader](https://github.com/webpack-contrib/postcss-loader) through `tools.postcss`.
|
|
34
34
|
|
|
35
|
+
It should be noted that when you enable the `tools.lightningcss` configuration, PostCSS will be disabled by default, including `postcss-loader` and its default plugins.
|
|
36
|
+
|
|
35
37
|
import RsbuildConig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
36
38
|
|
|
37
39
|
<RsbuildConig />
|
|
@@ -20,6 +20,12 @@ Modern.js has built-in [PostCSS](https://postcss.org/) to transform CSS code.
|
|
|
20
20
|
|
|
21
21
|
Please refer to [Rsbuild - Using PostCSS](https://rsbuild.dev/guide/basic/css-usage#using-postcss) for detailed usage.
|
|
22
22
|
|
|
23
|
+
## Using Lightning CSS
|
|
24
|
+
|
|
25
|
+
Modern.js supports using [Lightning CSS](https://lightningcss.dev/) to convert CSS code. This feature can be turned on by configuring [tools.lightningcssLoader](/configure/app/tools/lightningcss-loader).
|
|
26
|
+
|
|
27
|
+
Please refer to [Rsbuild - Using Lightning CSS](https://rsbuild.dev/guide/basic/css-usage#lightning-css) for detailed usage.
|
|
28
|
+
|
|
23
29
|
## Using Uno CSS
|
|
24
30
|
|
|
25
31
|
Please read the [Rsbuild - Using UnoCSS](https://rsbuild.dev/zh/guide/basic/unocss) for detailed usage.
|
|
@@ -60,6 +60,8 @@ During production builds, Modern.js uses [Terser](https://github.com/terser/ters
|
|
|
60
60
|
|
|
61
61
|
Modern.js uses [PostCSS](https://postcss.org/) to transform CSS code and enables [autoprefixer](https://github.com/postcss/autoprefixer) by default to add CSS prefixes.
|
|
62
62
|
|
|
63
|
+
Modern.js supports enabling ["Lightning CSS"](/configure/app/tools/lightningcss-loader), which uses Lightning CSS to downgrade CSS syntax.
|
|
64
|
+
|
|
63
65
|
Modern.js supports enabling ["Tailwind CSS"](/guides/basic-features/css/tailwindcss) and is compatible with both Tailwind CSS v2 and v3.
|
|
64
66
|
|
|
65
67
|
## CSS Preprocessors
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: lightningcssLoader
|
|
3
|
+
configName: tools.lightningcssLoader
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# tools.lightningcssLoader
|
|
7
|
+
|
|
8
|
+
- **类型:** `Rspack.LightningcssLoaderOptions | Function | boolean`
|
|
9
|
+
- **默认值:** `false`
|
|
10
|
+
- **打包工具:** `仅支持 rspack`
|
|
11
|
+
|
|
12
|
+
通过 `tools.lightningcssLoader` 可以设置 [builtin:lightningcss-loader](https://rspack.dev/guide/features/builtin-lightningcss-loader) 的选项。
|
|
13
|
+
|
|
14
|
+
## 开启 loader
|
|
15
|
+
|
|
16
|
+
将 `tools.lightningcssLoader` 设置为 `true`,可以开启 Rsbuild 内置的 `lightningcss-loader`:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default {
|
|
20
|
+
tools: {
|
|
21
|
+
lightningcssLoader: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
此时,默认生效的配置如下:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const defaultOptions = {
|
|
30
|
+
// use current browserslist config
|
|
31
|
+
targets: browserslist,
|
|
32
|
+
// minify is enabled when output.injectStyles is true and in production mode
|
|
33
|
+
minify: config.mode === 'production' && config.output.injectStyles,
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
需要注意的是,开启 `lightningcss-loader` 时,将会默认关闭 `postcss-loader`。
|
|
38
|
+
|
|
39
|
+
import RsbuildConig from '@site-docs/components/rsbuild-config-tooltip';
|
|
40
|
+
|
|
41
|
+
<RsbuildConig />
|
|
@@ -33,6 +33,8 @@ const defaultOptions = {
|
|
|
33
33
|
|
|
34
34
|
Modern.js 默认集成 PostCSS,你可以通过 `tools.postcss` 对 [postcss-loader](https://github.com/webpack-contrib/postcss-loader) 进行配置。
|
|
35
35
|
|
|
36
|
+
需要注意的是,当你开启 `tools.lightningcss` 配置时,PostCSS 将会被默认禁用,包括 `postcss-loader` 及其默认插件。
|
|
37
|
+
|
|
36
38
|
import RsbuildConig from '@site-docs/components/rsbuild-config-tooltip';
|
|
37
39
|
|
|
38
40
|
<RsbuildConig />
|
|
@@ -20,6 +20,12 @@ Modern.js 内置了 [PostCSS](https://postcss.org/) 来转换 CSS 代码。
|
|
|
20
20
|
|
|
21
21
|
请阅读 [Rsbuild - 使用 PostCSS](https://rsbuild.dev/zh/guide/basic/css-usage#%E4%BD%BF%E7%94%A8-postcss) 了解更多用法。
|
|
22
22
|
|
|
23
|
+
## 使用 Lightning CSS
|
|
24
|
+
|
|
25
|
+
Modern.js 支持使用 [Lightning CSS](https://lightningcss.dev/) 来转换 CSS 代码,可以通过配置 [tools.lightningcssLoader](/configure/app/tools/lightningcss-loader) 来开启此功能。
|
|
26
|
+
|
|
27
|
+
请阅读 [Rsbuild - 使用 Lightning CSS](https://rsbuild.dev/zh/guide/basic/css-usage#lightning-css) 了解更多用法。
|
|
28
|
+
|
|
23
29
|
## 使用 Uno CSS
|
|
24
30
|
|
|
25
31
|
请阅读 [Rsbuild - 使用 UnoCSS](https://rsbuild.dev/zh/guide/basic/unocss) 了解更多用法。
|
|
@@ -60,6 +60,8 @@ Modern.js 使用 [Babel](https://babeljs.io/)、[SWC](https://swc.rs/) 或 [esbu
|
|
|
60
60
|
|
|
61
61
|
Modern.js 使用 [PostCSS](https://postcss.org/) 来转换 CSS 代码,并默认开启 [autoprefixer](https://github.com/postcss/autoprefixer) 来补全 CSS 前缀。
|
|
62
62
|
|
|
63
|
+
Modern.js 支持 [启用 Lightning CSS](/configure/app/tools/lightningcss-loader),使用 Lightning CSS 降级 CSS 语法。
|
|
64
|
+
|
|
63
65
|
Modern.js 支持 [启用 Tailwind CSS](/guides/basic-features/css/tailwindcss),并同时兼容 Tailwind CSS v2 和 v3 版本。
|
|
64
66
|
|
|
65
67
|
## CSS 预处理器
|
package/package.json
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-nightly-
|
|
18
|
+
"version": "0.0.0-nightly-20241209170723",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public",
|
|
22
22
|
"provenance": true
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@modern-js/sandpack-react": "0.0.0-nightly-
|
|
25
|
+
"@modern-js/sandpack-react": "0.0.0-nightly-20241209170723"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@rspress/shared": "1.35.4",
|