Skip to content

Commit 5d59329

Browse files
committed
feat: Remove property generate_mode, we will always use depends_on
1 parent 327a074 commit 5d59329

38 files changed

+48
-447
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ npx iconfont-init
5858
"symbol_url": "请参考README.md,复制官网提供的JS链接",
5959
"use_typescript": false,
6060
"save_dir": "./src/iconfont",
61-
"generate_mode": "all-in-one",
6261
"trim_icon_prefix": "icon",
6362
"default_icon_size": 18,
6463
"summary_component_name": "Icon"
@@ -75,27 +74,14 @@ npx iconfont-init
7574
### use_typescript
7675
如果您的项目使用Typescript编写,请设置为true。这个选项将决定生成的图标组件是`.tsx`还是`.js`后缀。
7776

78-
当该值为false时,我们会为您的图标生成`.js``.d.ts`两个文件,以便您能享受到最好的开发体验。
79-
80-
### generate_mode
81-
生成组件的方式:
82-
##### 1、all-in-one
83-
只生成一个`<Icon name="xxx" />` 组件,里面包含了所有图标信息。所以这个组件会比较大。
84-
##### 2、depends-on
85-
每个图标都会生成一个组件`<IconXXX />`。这种模式也会生成一个`Icon`组件,但和all-in-one不同的是,这个Icon组件总是import其他的图标组件,它相当于一个门面。
86-
87-
------
88-
89-
现在,你可以参考[snapshots目录](https://github.com/fwh1990/react-native-iconfont-cli/tree/master/snapshots)的快照文件,以区分不同模式下的图标结构。
77+
当该值为false时,我们会为您的图标生成`.js``.d.ts`两种文件,以便您能享受到最好的开发体验。
9078

9179
### save_dir
9280
根据iconfont图标生成的组件存放的位置。每次生成组件之前,该文件夹都会被清空。
9381

9482
### trim_icon_prefix
9583
如果你的图标有通用的前缀,而你在使用的时候又不想重复去写,那么可以通过这种配置这个选项把前缀统一去掉。
9684

97-
注意,这个选项只针对 `<Icon />` 组件有效
98-
9985
### default_icon_size
10086
我们将为每个生成的图标组件加入默认的字体大小,当然,你也可以通过传入props的方式改变这个size值。
10187

@@ -108,7 +94,8 @@ npx iconfont-init
10894
```bash
10995
npx iconfont-rn
11096
```
111-
生成后查看您设置的保存目录中是否含有所有的图标
97+
98+
生成后查看您设置的保存目录中是否含有所有的图标,你可以参考**[snapshots目录](https://github.com/fwh1990/react-native-iconfont-cli/tree/master/snapshots)**的快照文件,以区分不同模式下的图标结构。
11299

113100
# 使用
114101
<br />
@@ -128,7 +115,7 @@ export const App = () => {
128115
};
129116
```
130117

131-
2、当您配置的`generate_mode=depends-on`时,您可以使用单个图标。这样可以避免没用到的图标也打包进App:
118+
2、使用单个图标。这样可以避免没用到的图标也打包进App:
132119

133120
```typescript jsx
134121
import IconAlipay from '../src/iconfont/IconAlipay';

scripts/config/all-in-one-ts.json

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"symbol_url": "http://at.alicdn.com/t/font_1373348_ghk94ooopqr.js",
33
"use_typescript": false,
4-
"generate_mode": "all-in-one",
5-
"save_dir": "./snapshots/all-in-one-js",
4+
"save_dir": "./snapshots/demo-js",
65
"trim_icon_prefix": "icon",
7-
"default_icon_size": 14,
6+
"default_icon_size": 18,
87
"summary_component_name": "Icon"
98
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"symbol_url": "http://at.alicdn.com/t/font_1373348_ghk94ooopqr.js",
33
"use_typescript": true,
4-
"generate_mode": "depends-on",
5-
"save_dir": "./snapshots/depends-on-ts",
4+
"save_dir": "./snapshots/demo-ts",
65
"trim_icon_prefix": "icon",
76
"default_icon_size": 20,
8-
"summary_component_name": "CustomIcon"
7+
"summary_component_name": "Icon_Custom_Name"
98
}

scripts/config/depends-on-js.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

scripts/update-snapshot.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#!/usr/bin/env bash
22

3-
cp -f ./scripts/config/all-in-one-js.json ./iconfont.json
4-
npx ts-node src/commands/createIcon.ts
5-
6-
cp -f ./scripts/config/all-in-one-ts.json ./iconfont.json
7-
npx ts-node src/commands/createIcon.ts
3+
rm -rf snapshots/*
84

9-
cp -f ./scripts/config/depends-on-js.json ./iconfont.json
5+
cp -f ./scripts/config/demo-js.json ./iconfont.json
106
npx ts-node src/commands/createIcon.ts
117

12-
cp -f ./scripts/config/depends-on-ts.json ./iconfont.json
8+
cp -f ./scripts/config/demo-ts.json ./iconfont.json
139
npx ts-node src/commands/createIcon.ts

snapshots/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

snapshots/all-in-one-js/Icon.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)