🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

gulp-append-rev

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-append-rev

解决静态资源缓存问题

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

gulp-append-rev

gulp打包静态资源添加版本号

installation

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

gulp打包设置

gulpfile.js

var rev = require('gulp-append-rev');

gulp.task('rev', function() {
  gulp.src('./index.html')
    .pipe(rev({root:"build"}))  
    .pipe(gulp.dest('.'));
});

gulp.task('rev', function() {
  gulp.src('./index.html')
    .pipe(rev())  
    .pipe(gulp.dest('.'));
});

what?

通过正则匹配处理: (?:href|src)="(.*)[\?]rev=(.*)[\"]

页面中加载静态资源:

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style/style-one.css?rev=@@hash">
    <script src="script/script-one.js?rev=@@hash"></script>
    <script src="script/script-two.js"></script>
  </head>
  <body>
    <div><p>hello, world!</p></div>
    <script src="script/script-three.js?rev=@@hash"></script>
  </body>
</html>

执行以后 gulp-append-rev:

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style/style-one.css?rev=d65aaba987e9c1eefeb4be9cfd34e0de">
    <script src="script/script-one.js?rev=17a5da6c8a2d875cf48aefb722eefa07"></script>
    <script src="script/script-two.js"></script>
  </head>
  <body>
    <div><p>hello, world!</p></div>
    <script src="script/script-three.js?rev=5cadf43edba6a97980d42331f9fffd17"></script>
  </body>
</html>

该模块,通过修改模块gulp-rev-append而来,扩展参数配置功能

Keywords

gulp-append-rev

FAQs

Package last updated on 04 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts