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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pz4l/tinyimg-webpack

v0.0.4

Published

[![npm version](https://img.shields.io/npm/v/@pz4l/tinyimg-webpack)](https://www.npmjs.com/package/@pz4l/tinyimg-webpack)

Readme

@pz4l/tinyimg-webpack

npm version

用于 Webpack 的 TinyPNG 图片压缩插件。

Peer dependency: webpack ^5.0.0

安装

npm i -D @pz4l/tinyimg-webpack

使用

零配置使用:

// webpack.config.ts
import TinyimgWebpackPlugin from '@pz4l/tinyimg-webpack'

export default {
  plugins: [new TinyimgWebpackPlugin()],
}

带配置:

// webpack.config.ts
import TinyimgWebpackPlugin from '@pz4l/tinyimg-webpack'

export default {
  // ...other config
  plugins: [
    new TinyimgWebpackPlugin({
      strategy: 'AUTO',
      maxFileSize: 5 * 1024 * 1024,
      convertPngToJpg: false,
      parallel: 3,
    }),
  ],
}

配置项

| 配置项 | 类型 | 默认值 | 说明 | | --------------- | ------------------------------------------------- | ----------------- | ------------------------------- | | strategy | 'API_ONLY' \| 'RANDOM' \| 'API_FIRST' \| 'AUTO' | 'AUTO' | 压缩策略 | | maxFileSize | number | 5 * 1024 * 1024 | 本地预压缩前的单个文件最大大小 | | convertPngToJpg | boolean | false | 是否将无透明通道的 PNG 转为 JPG | | parallel | number | 3 | 最大并行压缩数量 |

压缩策略说明

  • API_ONLY: 始终使用 TinyPNG API。需要提供 API key。
  • RANDOM: 随机在 API 和 Web 端点之间选择。
  • API_FIRST: 优先使用 TinyPNG API;当 API key 无效或触发限流时回退到 Web 端点。
  • AUTO: 有 API key 时等同于 API_FIRST,否则等同于 RANDOM

API Key 设置

插件本身不读取 .env 文件;由构建工具(Webpack)加载。建议使用 .env.local 存放本地密钥。

支持的变量名:任何以 TINYIMG_KEYTINYIMG_KEYSTINYPNG_KEYTINYPNG_KEYS 结尾的变量。你也可以添加前缀,例如 APP_TINYIMG_KEY

示例:

TINYIMG_KEY=your_api_key

示例

参见仓库中的 examples/webpack 获取可运行的示例。

许可证

MIT