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

gulp-weapp-replace-image

v1.0.1

Published

一款可自自动替换微信小程序项目中图片的 gulp 插件

Readme

自动替换微信小程序中的本地图片为 cdn 地址

原由

一些小程序项目从一开始规划就没有把图片放在cdn上,但小程序迭代过几个版本之后就会发现,日益增长的图片已经达到了小程序中的包大小限制。这个时候就会从分包、减少本地图片来解决,但一个项目中的图片可能都会有上百张的大小。 一个一个的替换这样肯定不是一个程序猿的作风。我的这个gulp的插件就是为了解决这个问题,全自动替换、分分钟搞定你的烦心事。

使用

	const gulpWeappReplaceImage = require('gulp-weapp-replace-image'

	gulp.task('replace-image',function(){
		return gulp.src(['./**/*.wxml','./**/*.scss','./**/*.wxss','./**/*.js','!./node_modules/**/*.*'])
		.pipe(gulpWeappReplaceImage({uploader: uploader}))
		.pipe(gulp.dest('./'))
	})
	function uploader(filePath){
		return new Promise((resolve,reject)=>{
			// 图片上传
		})
	}

然后运行

	gulp replace-image

注意

uploader 上传还是要自己写的,毕竟没有什么免费的云服务,uploader 返回为一个 Promise,这里还需要注意上传的cdn的域名需要在小程序的后台中配置域名校验。 上传替换完成之后,会自动删除图片,释放小程序中的包大小。

图片替换记录

文件替换完成之后,会在项目根目录下生成一个 analyse.html 包含 已替换的文件& 没有替换的图片,这个是有可能图片已经被移除了,需要自行check一下代码

建议

上传图片前需要确认一下自己的图片是否需要压缩,gulp的图片压缩插件比较多,这里就不重复造轮子了。