Files
ionicons/scripts
Adam Bradley 66556ea45c feat(custom-elements): export ionicons/components
Also provide ionicons as a custom element which can be defined using `customElements.define()`

```
import { IonIcon } from "ionicons/components/ion-icon";
customElements.define("ion-icon", IonIcon);
```

The custom element build works the same as the lazy load build, and is also able to lazy load svgs on demand, either by giving it an exact url in the `src` attribute `<ion-icon src="./path/to/airplane.svg"></ion-icon>`, or by providing the name of the ionicon to load `<ion-icon name="airplane"></ion-icon>`.

If using the `name` attribute, you'll also need to set where to find the svg directory using `setAssetPath()`

```
import { setAssetPath } from "ionicons/components";
setAssetPath(location.href);
```
2021-02-01 15:28:33 -06:00
..
2019-09-18 12:54:52 -05:00
2020-10-06 09:33:28 -05:00

Development and Build Scripts

Updating Icons

The src/svg directory is the single source of truth for svgs. They should not already be optimized and can be the original svg export straight out of an svg editor. A build step before releasing will optimize the source svgs (remove comments, reduce the size, etc) and ensure they'll work within ion-icon.

Build Locally

After an svg has been updated, added or deleted from the src/svg directory, run:

npm run build

The build command will optimize all of the icons and generate the files to be distributed. After the build command, all of the optimized svgs are saved in dist/ionicons/svg. Additionally the dist directory contains the distribution files for the ion-icon web component.

Svg Symbols Cheatsheet

After a build, a new www/cheatsheet.html file will be created. This version uses svg symbols rather than ion-icon.

ion-icon Component Preview

To see the ion-icon component in action, run:

npm start

Release Steps

npm run release.prepare

The release script will ask what version to use. After the script completes, double check the www/cheatsheet.html to ensure everything is good to go.

Next, update CHANGELOG.md, then commit and push your changes Github.

Next run:

npm run release

Triple check the version number is correct, and choose which tag this should be released as. If it's a pre-release, it should be dev.