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-file-version

v2.0.11

Published

Add suffix to reference.

Downloads

16

Readme

Feature

  • Add a version info to your script references in *.html file

Environment

  • node version >= 6.0.0

Install

npm install gulp-file-version

###Example


#### Before
<html>
	...
		<script src="./common/app.js"></script>
	...
</html>

### After
<html>
	...
		<script src="./common/app.js?v=12fa31"></script>
	...
</html>

###Code

gulp.task("fv", function (cb) {
    return gulp.src("./dist/*.html")//your source file
     .pipe(fv())//use gulp-file-version to add version information of script and link's reference
     .pipe(gulp.dest("./dist"));//output

});

##API #####fv(Regexp[, options]) Use custom regexp match source file.Add version info to the matched element, which is a file and must be existed. options: < Object >

  • base: < String >specify the root path of the reference file path。default path is the directory where the gulpfile.js in。
  • Hash: < String >The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform.Examples are 'sha256', 'sha512', etc. Default is a sum of the ascii in file.

Example:

gulp.task("tv", function(cb){//匹配angularjs中templateUrl引用文件并添加版本信息
    return gulp.src("./dist/**/*.js")
        .pipe(fv(/templateUrl:["']{1}([\w./-]*)["']{1}/g,{base: "./app", Hash: "md5"}))
        .pipe(gulp.dest("./dist"));
});

Result:

path   ./app/assets.js
###Before
...
var something = {
        templateUrl:"./assets/assets.html"
    };
...

###After
...
var something = {
        templateUrl:"./assets/assets.html?v=ed36a41cd9"
    };
...

PS: the old version before 2.0.0 of has been deprecated.The new version is more easy to use,and less error.

特性

  • 为*.html文件的引用添加版本信息

环境

  • node 版本 >= 6.0.0

###示例


#### Before
<html>
	...
		<script src="./common/app.js"></script>
	...
</html>

### After
<html>
	...
		<script src="./common/app.js?v=12fa31"></script>
	...
</html>

###代码


gulp.task("fv", function (cb) {
    return gulp.src("./dist/*.html")//你的源文件
     .pipe(fv())//运行gulp-file-version,为文件中的script和link引用文件添加版本
     .pipe(gulp.dest("./dist"));//输出

});

##API #####fv(Regexp[, options]) 用自定义的正则表达式匹配源文件内容,为其中满足条件的匹配项(文件路径)添加版本信息(该文件必须存在,否则报错) options: < Object >

  • base: < String >指定引用文件的根路径。默认为执行该任务所在文件的路径。
  • Hash: < String >版本信息所使用的编码方式。默认为文件ascii码之和。可选"md5","sha256","sha512"。

Example:

gulp.task("tv", function(cb){//匹配angularjs中templateUrl引用文件并添加版本信息
    return gulp.src("./dist/**/*.js")
        .pipe(fv(/templateUrl:["']{1}([\w./-]*)["']{1}/g,{base: "./app", Hash: "md5"}))
        .pipe(gulp.dest("./dist"));
});

Result:

path   ./app/assets.js
###Before
...
var something = {
        templateUrl:"./assets/assets.html"
    };
...

###After
...
var something = {
        templateUrl:"./assets/assets.html?v=ed36a41cd9"
    };
...

PS: 2.0.0之前的旧版本已经弃用。新版本使用更为简单且错误更少。