Giter Club home page Giter Club logo

gulp-rev-happy's Introduction

gulp-rev-happy

给资源文件添加文件指纹,改进自 gulp-rev2

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

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

处理了rev2的一些问题:

1、不能为html和js文件添加指纹
2、多次调用update,导致的指纹累积 ?v=560396f564?v=560396f564
3、如果原本的链接带了url参数,导致出现两个问号 ?v=560396f564?aaa=bbb
4、同一个gulp的task中,生成manifest后马上调用update,因为require缓存不能读取刚生成的manifest

Install

$ npm install --save-dev gulp-rev-happy  

Usage1 使用url参数方式构建文件指纹

demo1

Usage2 使用文件改名方式构建文件指纹

demo2

设计思路

修改自 gulp-rev , gulp-rev-collectorgulp-rev2 ,主要实现如下:

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

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

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

配置项

rev([opts])

query

Type: boolean

Default: false

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

其他配置项同 gulp-rev-collector

collectedManifest 指定需要合并的manifest文件

replaceReved 允许替换已经替换过的文件

dirReplacements 目录替换

revSuffix 文件指纹生成方式

extMap 扩展名替换

gulp-rev-happy's People

Contributors

lbnnbs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.