@angular-extensions/svg-icons-builder

中文文档
11.0.0发布于 2024/02/13MIT近 30 天下载 3.3万

The svg-icons-builder is a Angular builder for the svg-to-ts project

原始使用文档
文档目录8 节
  1. Usage
  2. Installation
  3. Configure the builder
  4. conversionType: constants
  5. conversionType: files
  6. conversionType: object
  7. Run the builder
  8. Core Team ✨

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

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. ⚠️ 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"]
      }
  }
}

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"]
      },
      "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"]
      },
      "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!

版本与发布记录

@angular-extensions/svg-icons-builder 共发布 5 个版本,首次发布于 2020/11/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
11.0.0latest2024/02/132 年前
3.0.02021/12/024 年前
2.0.02021/08/205 年前
1.1.02021/01/185 年前
1.0.02020/11/165 年前

关于 @angular-extensions/svg-icons-builder 的常见问题

@angular-extensions/svg-icons-builder 是什么?

The svg-icons-builder is a Angular builder for the svg-to-ts project

如何安装 @angular-extensions/svg-icons-builder?

在项目目录运行 npm install @angular-extensions/svg-icons-builder,或使用 pnpm add / yarn add / bun add。

@angular-extensions/svg-icons-builder 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/angular-extensions__svg-icons-builder 是否存在。

@angular-extensions/svg-icons-builder 可以商用吗?

@angular-extensions/svg-icons-builder 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@angular-extensions/svg-icons-builder 的下载量有多少?

根据 npm 官方下载统计,@angular-extensions/svg-icons-builder 在 2026/10/06 – 2026/11/04 这 30 天内被下载 33,342 次,日均约 1,111 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angular-extensions/svg-icons-builder 还在维护吗?

最新版本 11.0.0 发布于 2024/02/13(2 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/11/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。