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

gulp-rev3

v1.0.6

Published

improve gulp-rev

Downloads

2

Readme

gulp-rev2

给资源文件添加文件指纹

a.pnga-f7ee61d96b.png(文件名方式)

a.pnga.png?_v_=f7ee61d96b(url参数方式)

Install

$ npm install --save-dev gulp-rev2

Usage

const gulp = require('gulp');
const rev2 = require('gulp-rev2');

gulp.task('build:image', ()=>{
    return gulp.src('./demo/**/*.{png,jpg,gif,ico}')
        .pipe(rev2({                // 生成文件指纹并修改文件名
            // 以 query string的方式进行指纹关联, 默认使用修改文件名方式进行关联   
            query: true,            
        }))
        .pipe(gulp.dest('dist'))    // 输出到 dist 目录
        .pipe(rev2.manifest())      // 生成映射对照表 rev-manifest.js
        .pipe(gulp.dest('.'));      // 输出到 gulpfile.js 同级目录
});

gulp.task('build:css', ['build:image'], ()=>{
    return gulp.src('./demo/**/*.css')
        .pipe(rev2.update())        // 根据映射对照表更新存在引用的父文件
        .pipe(gulp.dest('dist'))
});

设计思路

gulp-rev2 主要借鉴了 gulp-revgulp-rev-collector 的设计实现,主要实现思路如下:

  1. 根据文件的内容 file.contents 生成文件指纹(hash值);

  2. 根据前面生成的文件指纹集合成一张(源文件,构建文件)映射对照表(并保存在清单文件 rev-manifest.json 中);

  3. 根据前面生成的映射对照表级联更新存在引用的父文件;

配置项

rev2([opts])

query

Type: boolean Default: false

设置文件指纹的关联方式,true 通过url参数关联 a.pnga.png?_v_=f7ee61d96bfalse 通过文件名关联 a.pnga-f7ee61d96b.png

Demo

这里有一个栗子:gulp-rev2-demo

这里有一篇教程:给资源文件添加指纹(Gulp版)