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

lylb

v0.1.5

Published

commonjs

Readme

描述说明

项目中包含以下功能模块

  1. 本地图片文件批量上传七牛云,并替换本地文件路径为七牛云图片路径。默认查找 src 目录
    目录下的以.css .less .vue 格式结尾的文件
    七牛云的配置信息文件在.env 文件中,项目根目录下创建.env 文件
.env
QINIU_ACCESS_KEY=
QINIU_SECRET_KEY=
QINIU_BUCKET=
QINIU_DOMAIN=
QINIU_CDN_URL=
QINIU_PREFIX=
  1. 本地 dist 文件发布服务器,在.env 配置服务器信息
.env

SERVER_NAME=服务器名称
SERVER_HOST=服务器ip
SERVER_USERNAME=服务器用户名
SERVER_PASSWORD=服务器密码
SERVER_PATH=服务器文件路径

多服务器可以一次增加配置信息, 如:
SERVER_NAME_1=
SERVER_HOST_1=
SERVER_USERNAME_1=
SERVER_PASSWORD_1=
SERVER_PATH_1=

如果共用一个服务器,不同的文件夹,只需要增加 SERVER_PATH_1 服务器文件路径配置即可

  1. 代码推送到仓库

配合 package.json 的 script 脚本使用 例:

npm run push 提交代码
  1. 压缩图片

默认压缩目录下 src 文件夹内的图片,压缩后覆盖替换图片,可以配置 COMPRESS_PATH 修改文件

.env
COMPRESS_PATH=/src
  1. 压缩字体 默认压缩目录下fonts文件夹内的字体文件,压缩后生成一个fontmin/fonts文件夹,放置压缩后的字体文件

安装使用

安装依赖
npm i lylb -D

引入文件
const lylb = require('lylb');

方法说明

获取七牛云上传的token
lylb.getQiniuToken()

上传图片到七牛云
@param {String} localFile 本地文件绝对路径
lylb.uploadFile(localFile)

配置上传参数
@param {Object} config
config = {
    path: path.resolve(process.cwd(), "src"),  // 上传文件路径
    prefix: env.QINIU_PREFIX || "images/frontend", // 上传key前缀
    isTimestamp: 0, // 是否添加时间戳前缀
    isOverwrite: 0, // 是否覆盖上传
    filePrefix: "src", // 截取文件的目录前缀,作为上传key的一部分
}   // 配置默认值
setUploadConfig(config)

文件内图片上传七牛云
@param {String} path 文件夹路径 /src
lylb.filesImgToQiniu(path)

上传指定文件夹下的文件
@param {String} path 文件夹路径 /src
uploadDirFile(path)

查询指定文件前缀的图片
@param {String} prefix 文件前缀
@param {Number} limit 查询条数
lylb.getQiniuImg(prefix = uploadConfig.prefix, limit = 10)

删除指定文件前缀的图片
@param {String} prefix 文件前缀
@param {Number} limit 查询条数
lylb.delQiniuImg(prefix = uploadConfig.prefix, limit = 10)

发布代码到服务器
@param {String} distFolder 打包的文件路径
lylb.deploy(distFolder = "dist")

推送代码
lylb.gitPush()

@param {String} distFolder 编译后的文件夹
@param {String} buildFolder 提交git的文件夹
lylb.release(distFolder = "dist", buildFolder = "build")

图片压缩
@param {String} folder 图片所在的文件夹路径
@param {String} outFolder 图片压缩后存放的文件夹路径,不传默认替换源文件
lylb.imageOptim(folder, outFolder) // 默认src目录

压缩字体文件
@param {String} font 需要单独压缩的文字
lylb.fontmin(font)

使用实例参考

新建 lylb.js 文件,配合 package.json 的 script 脚本执行

lylb.js
const lylb = require("lylb");
const argv = require("yargs").argv._[0];

switch (argv) {
    case "deploy":
        lylb.deploy();
        break;
    case "release":
        lylb.release();
        break;
    case "push":
        lylb.gitPush();
        break;
    case "qiniu":
        lylb.filesImgToQiniu();
        break;
    case "img":
        lylb.imageOptim();
        break;
    case "fontmin":
        lylb.fontmin();
        break;
    default:
        break;
}

package.json
{
    "scripts": {
        "deploy": "node lylb.js deploy",
        "release": "node lylb.js release",
        "qiniu": "node lylb.js qiniu",
        "push": "node lylb.js push",
        "img": "node lylb.js img"
    },
}