Skip to content

Commit c14190a

Browse files
committed
fix: 新版本修复类型定义问题
1 parent 5abff98 commit c14190a

File tree

7 files changed

+55
-15
lines changed

7 files changed

+55
-15
lines changed

packages/vite/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ module.exports = {
9494
};
9595
```
9696

97+
### Rsbuild
98+
99+
Thanks to @SamuNatsu for the addition.
100+
101+
[TS Type Configuration](#typescript-support)
102+
103+
```js
104+
export default defineConfig({
105+
// ...
106+
tools: {
107+
bundlerChain(chain, { CHAIN_ID }) {
108+
chain.module.rule(CHAIN_ID.RULE.FONT).exclude.add(/\.(ttf|otf)$/); // Require RsBuild not to process .ttf files
109+
},
110+
rspack: {
111+
plugins: [pluginFont.rspack()], // Register plugin in RsPack
112+
},
113+
},
114+
// ...
115+
});
116+
```
117+
97118
## 🚀 Usage
98119

99120
```jsx

packages/vite/README_zh.md

+21
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ module.exports = {
9494
};
9595
```
9696

97+
### Rsbuild
98+
99+
感谢 @SamuNatsu 补充
100+
101+
[TS 类型配置](#typescript-支持)
102+
103+
```js
104+
export default defineConfig({
105+
// ...
106+
tools: {
107+
bundlerChain(chain, { CHAIN_ID }) {
108+
chain.module.rule(CHAIN_ID.RULE.FONT).exclude.add(/\.(ttf|otf)$/); // 要求 RsBuild 不处理 .ttf 文件
109+
},
110+
rspack: {
111+
plugins: [pluginFont.rspack()], // 在 RsPack 中注册插件
112+
},
113+
},
114+
// ...
115+
});
116+
```
117+
97118
## 🚀 Usage
98119

99120
```jsx

packages/vite/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "5.1.0",
2+
"version": "5.1.1",
33
"name": "vite-plugin-font",
44
"description": "An automatic Web Font optimization plugin that supports many platforms such as Vite, Next, Nuxt, and more.",
55
"main": "./dist/unplugin.js",
@@ -55,7 +55,7 @@
5555
},
5656
"dependencies": {
5757
"cn-font-metrics": "^2.1.6",
58-
"cn-font-split": "^7.2.2",
58+
"cn-font-split": "^7.2.4",
5959
"fontaine": "^0.5.0",
6060
"fs-extra": "^11.2.0",
6161
"glob": "^11.0.1",

packages/vite/src/font.d.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
declare module '@konghayao/_font_' {
2-
import { fontSplit } from 'cn-font-split';
3-
type Reporter = Awaited<ReturnType<typeof fontSplit>>;
4-
export const css: Reporter['css'];
2+
import { type FontReporter } from 'cn-font-split/dist/interface';
3+
export const css: NonNullable<FontReporter['css']>;
54
}
65

76
declare module '*.ttf' {

packages/vite/src/subset/SubsetBundlePlugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export class SubsetBundlePlugin extends BundlePlugin {
9999
const stream = fs.createReadStream(i, {
100100
encoding: 'utf8',
101101
});
102-
stream.on('data', (i: string) => {
103-
[...i].forEach((char) =>
102+
stream.on('data', (i) => {
103+
[...(i as string)].forEach((char) =>
104104
this.usedSubsets.add(char.codePointAt(0)!),
105105
);
106106
});

packages/vite/src/unplugin.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
SubsetUtils,
77
} from './subset/SubsetBundlePlugin.js';
88
import { normalizePath } from './utils/normalizePath.js';
9-
109
export interface Options extends Partial<SubsetBundlePluginConfig> {
1110
/**
1211
* 默认为 [/\.otf/, /\.ttf/]

pnpm-lock.yaml

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)