mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-12-01 16:56:28 +01:00
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);
```
30 lines
489 B
TypeScript
Executable File
30 lines
489 B
TypeScript
Executable File
import { Config } from '@stencil/core';
|
|
|
|
export const config: Config = {
|
|
namespace: 'ionicons',
|
|
outputTargets: [
|
|
{
|
|
type: 'dist',
|
|
empty: false,
|
|
},
|
|
{
|
|
type: 'dist-custom-elements',
|
|
dir: './components',
|
|
},
|
|
{
|
|
type: 'docs-readme',
|
|
},
|
|
{
|
|
type: 'www',
|
|
copy: [
|
|
{
|
|
src: './components/test/*.svg',
|
|
dest: './assets/',
|
|
},
|
|
],
|
|
empty: false,
|
|
serviceWorker: false,
|
|
},
|
|
],
|
|
};
|