Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/angular-extensions/svg-icons-builder
Angular builder to build svg-icons using svg-to-ts
https://github.com/angular-extensions/svg-icons-builder
Last synced: about 2 months ago
JSON representation
Angular builder to build svg-icons using svg-to-ts
- Host: GitHub
- URL: https://github.com/angular-extensions/svg-icons-builder
- Owner: angular-extensions
- License: mit
- Created: 2020-10-15T06:15:04.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T07:39:11.000Z (11 months ago)
- Last Synced: 2024-11-05T10:14:55.164Z (2 months ago)
- Language: TypeScript
- Size: 801 KB
- Stars: 20
- Watchers: 1
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-angular - svg-icons-builder - Angular builder to build svg-icons using svg-to-ts. (Table of contents / Third Party Components)
- fucking-awesome-angular - svg-icons-builder - Angular builder to build svg-icons using svg-to-ts. (Table of contents / Third Party Components)
README
# svg-icons-builder
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
The svg-icons-builder is a Angular builder for the [svg-to-ts](https://github.com/kreuzerk/svg-to-ts) project. It can be used to convert SVG icons inside an Angular library or SPA to an object, to constants or even to individual TypeScript or JavaScript files.
Find out more on the official [svg-to-ts docs](https://github.com/kreuzerk/svg-to-ts).## Usage
### Installation
NPM: `npm install @angular-extensions/svg-icons-builder`
Angular CLI: `ng add @angular-extensions/svg-icons-builder`
### Configure the builder
To use the builder you need to add a new entry to your `architect` object inside your `angular.json`.
A valid [svg-to-ts configuration](https://github.com/kreuzerk/svg-to-ts). ⚠️ the options depend on the `conversionType` and may therefore vary. Means, a configuration for the `convesionType: "files"` will look different than configuration for the `conversionType: "constants"`. Each `conversionType` has it's own builder.
In our example we call it `generate-icons`. You then need to specify the following properties:
## `conversionType: constants`
- **Builder**: `"@angular-extensions/svg-icons-builder:svg-icons-constants-builder"`
- **Config**: [svg-to-ts constants config](https://github.com/kreuzerk/svg-to-ts#2-multiple-constants---treeshakable-and-typesafe-with-one-file-conversiontypeconstants)```json
"generate-icons": {
"builder": "@angular-extensions/svg-icons-builder:svg-icons-constants-builder",
"options": {
"conversionType": "constants",
"fileName": "myIcons",
"generateType": false,
"generateTypeObject": false,
"generateCompleteIconSet": true,
"srcFiles": ["./src/icons/*.svg"],
"outputDirectory": "./dist/icons",
"interfaceName": "DinosaurIcon",
"typeName": "dinosaurIcon",
"prefix": "dinosaurIcon",
"svgoConfig": {
"plugins": ["cleanupAttrs"]
}
}
}
```## `conversionType: files`
- **Builder**: `"@angular-extensions/svg-icons-builder:svg-icons-files-builder"`
- **Config**: [svg-to-ts files config](https://github.com/kreuzerk/svg-to-ts#3-tree-shakable-and-optimized-for-lazy-loading-conversiontypefiles)```json
"generate-icons": {
"builder": "@angular-extensions/svg-icons-builder:svg-icons-files-builder",
"options": {
"conversionType": "files",
"srcFiles": ["./projects/dinosaur-icons/icons/**/*.svg"],
"outputDirectory": "./dist/dinosaur-icons/icons",
"interfaceName": "DinosaurIcon",
"generateType": false,
"generateTypeObject": false,
"generateCompleteIconSet": false,
"exportCompleteIconSet": false,
"fileName": "dinosaur-icons",
"iconsFolderName": "dinosaur-icons",
"objectName": "dinosaur-icons",
"typeName": "dinosaurIcon",
"prefix": "dinosaurIcon",
"modelFileName": "dinosaur-icons",
"barrelFileName": "index",
"svgoConfig": {
"plugins": ["cleanupAttrs"]
},
"compileSources": true
}
}
```## `conversionType: object`
- **Builder**: `"@angular-extensions/svg-icons-builder:svg-icons-object-builder"`
- **Config**: [svg-to-ts object config](https://github.com/kreuzerk/svg-to-ts#1-converting-to-a-single-object-conversiontypeobject)```json
"generate-icons": {
"builder": "@angular-extensions/svg-icons-builder:svg-icons-object-builder",
"options": {
"conversionType": "object",
"srcFiles": ["./projects/dinosaur-icons/icons/**/*.svg"],
"outputDirectory": "./dist/dinosaur-icons/icons",
"fileName": "dinosaur-icons",
"objectName": "dinosaur-icons",
"svgoConfig": {
"plugins": ["cleanupAttrs"]
},
"compileSources": true
}
}
```### Run the builder
In order to run the builder you have to add a new npm script to your `package.json`. Replace `name-of-your-app` with the name of your application 😉.
```json
"genrate-icons": "ng run name-of-your-app:generate-icons"
```## Core Team ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Kayla Altepeter
💻 🐛 📖 🤔 ⚠️
Kevin Kreuzer
💻 🐛 📖 🤔 ⚠️
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!