Git Product home page Git Product logo

svg-icons-builder's Introduction

svg-icons-builder

All Contributors

The svg-icons-builder is a Angular builder for the 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.

Usage

Installation

NPM: npm install @angular-extensions/svg-icons-builder

Angular CLI: ng add @angular-extensions/svg-icons-builder

Configuring 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. โš ๏ธ 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

"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": true
         }
        ]
      }
  }
}

conversionType: files

  "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": true
          }
        ]
      },
      "compileSources": true
    }
  }

conversionType: object

  "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": true
          }
        ]
      },
      "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 ๐Ÿ˜‰.

"genrate-icons": "ng run name-of-your-app:generate-icons"

Core Team โœจ

Thanks goes to these wonderful people (emoji key):


Kayla Altepeter

๐Ÿ’ป ๐Ÿ› ๐Ÿ“– ๐Ÿค” โš ๏ธ

Kevin Kreuzer

๐Ÿ’ป ๐Ÿ› ๐Ÿ“– ๐Ÿค” โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!

svg-icons-builder's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.