Skip to content

Commit b737c28

Browse files
jinghaihansxzz
andauthored
feat: generate CSS exports when css.splitting is disabled (#680)
Co-authored-by: Kevin Deng <sxzz@sxzz.moe>
1 parent ebb94a9 commit b737c28

File tree

4 files changed

+311
-53
lines changed

4 files changed

+311
-53
lines changed

docs/options/package-exports.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ export default defineConfig({
6363

6464
This is especially useful when combined with TypeScript's [`customConditions`](https://www.typescriptlang.org/tsconfig/#customConditions) option, allowing you to control which conditions use the source code.
6565

66+
## CSS Exports
67+
68+
When `css.splitting` is `false`, the bundled CSS file is automatically added to `exports`:
69+
70+
```ts
71+
export default defineConfig({
72+
css: {
73+
splitting: false,
74+
},
75+
exports: true,
76+
})
77+
```
78+
79+
The CSS filename defaults to `style.css` and can be customized via `css.fileName`.
80+
6681
## Customizing Exports
6782

6883
If you need more control over the generated exports, you can provide a custom function via `exports.customExports`:

docs/zh-CN/options/package-exports.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ export default defineConfig({
6363

6464
这在结合 TypeScript 的 [`customConditions`](https://www.typescriptlang.org/tsconfig/#customConditions) 选项时尤其有用,可以灵活控制哪些条件下使用源码。
6565

66+
## CSS 导出
67+
68+
`css.splitting``false` 时,打包后的 CSS 文件会自动添加到 `exports` 中:
69+
70+
```ts
71+
export default defineConfig({
72+
css: {
73+
splitting: false,
74+
},
75+
exports: true,
76+
})
77+
```
78+
79+
CSS 文件名默认为 `style.css`,可通过 `css.fileName` 自定义。
80+
6681
## 自定义导出
6782

6883
如果您需要对生成的导出字段进行更细致的控制,可以通过 `exports.customExports` 提供自定义函数:

0 commit comments

Comments
 (0)