npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nz-ssvgg

v0.0.7

Published

NG-ZORRO Super SVG generator

Downloads

18

Readme

NPM version Downloads MIT License

这是什么?

这个工具会尽可能从你的项目找到使用过的 Icon,然后帮你生成按需引入的文件。对于没有匹配到的(比如动态生成)图标,NG-ZORRO 会自动使用动态加载的方式请求。

为什么?

[email protected] 版本后,使用了 svg 图标替换了原先的 font 图标,从而带来了以下劣势(误):

  • 全量静态引入时带来包体积增加
  • 动态加载时会在没有缓存的情况下带来多余的请求(相比之前)

如何使用?

通过 npm 或者 yarn 安装。

$ npm i nz-ssvgg -g

在项目目录下运行

$ nz-ssvgg

或者指定项目根目录

$ nz-ssvgg hsuanlee/ng-project

如果一切正常你可以在你项目的下找到 src/ant-svg-icons.ts 文件,看起来像这样:

import {
    AndroidOutline,
    AppleOutline,
    NotificationOutline,
    PaperClipOutline,
...
 } from '@ant-design/icons-angular/icons';

export const ANT_ICONS = [
    AndroidOutline,
    AppleOutline,
    NotificationOutline,
    PaperClipOutline,
  ...
];

接下来按照官方文档添加图标即可,就像这样:

import { ANT_ICONS } from '../ant-svg-icons.ts';
import { NzIconService } from 'ng-zorro-antd';

export class AppComponent implements OnInit, AfterViewInit {
  constructor(private iconService: NzIconService) {
    // Import what you need.
    this.iconService.addIcon(...ANT_ICONS);
  }
}

以下情况无法匹配

<i nz-icon type="{{express}}" theme="{{express}}"></i>
<i class="anticon {{express}}"></i>
<i [attr.class]="express"></i>
<i [ngClass]="express"></i>

它是怎么工作的?

  1. 读取你项目的 angular.json 文件,找到默认项目
  2. 遍历项目文件进行匹配
  3. 生成按需导入文件夹