You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is used to uniquely group the ionIcons in a project and export them from `use-icons.ts`. In small projects, it is difficult to manage `addIcons()` of ionIcons each time, so we automated it.
5
+
This library is used to uniquely group the ionIcons in a project, and generate for export ionIcons file. In small projects, it is difficult to manage `addIcons()` of ionIcons each time, so we automated it.
6
6
7
-
- development: Stress-free development by `addIcons()` for all icons.
7
+
- development: Stress-free development by add all icons at `addIcons`.
8
8
- Production: Automatically collect and update the ionIcon used in the template prior to build.
9
9
10
10
Of course, to maximize bundle size reduction, it is important to load a minimum number of icons at each Component lazy loading. This is a compromise to speed up development.
@@ -14,17 +14,32 @@ This project is based [ionic-team/ionic-angular-standalone-codemods](https://git
14
14
> [!WARNING]
15
15
> This project is experimental. Review all changes before committing them to your project.
This will overwrite `use-icons.ts` if it exists, or automatically generate `src/use-icons.ts` if not. If you wish to place this file in an arbitrary location, move it.
40
+
This will generate `src/use-icons.ts`.
26
41
27
-
2. Import the generated file in your `main.ts` ( or `app.config.ts` ) file:
42
+
#### 2. Import the generated file in your `main.ts` ( or `app.config.ts` ) file:
28
43
29
44
```diff
30
45
+ import { addIcons } from 'ionicons';
@@ -38,22 +53,111 @@ This will overwrite `use-icons.ts` if it exists, or automatically generate `src/
#### 3. Remove other `addIcons` calls in class constructor
42
57
43
-
Yes. Please check this issue: https://github.com/ionic-team/ionic-framework/issues/28445#issuecomment-1789028722
58
+
```diff
59
+
@Component(/* ... */)
60
+
export class ExampleComponent {
61
+
constructor() {
62
+
- addIcons(useIcons);
63
+
}
64
+
}
65
+
```
44
66
45
-
> You're more than welcome to register them in main.ts or app.component.ts. You can then use them anywhere in your application. However, the initial bundle size may increase because the icons need to be loaded up front.
67
+
## Usage
46
68
47
-
3. Add npm script for generate `use-icons.ts` file at every build:
69
+
```bash
70
+
npx @rdlabo/ionic-angular-collect-icons
71
+
```
72
+
73
+
### Let's automate run
74
+
75
+
It is inefficient to run commands each time before running a production build, so put them in an npm script to automate the process. Example:
Yes. Please check this issue: https://github.com/ionic-team/ionic-framework/issues/28445#issuecomment-1789028722
158
+
159
+
> You're more than welcome to register them in main.ts or app.component.ts. You can then use them anywhere in your application. However, the initial bundle size may increase because the icons need to be loaded up front.
0 commit comments