• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

shinate/gulp-version-number: Add version number to js/css/image in HTML

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

shinate/gulp-version-number

开源软件地址(OpenSource Url):

https://github.com/shinate/gulp-version-number

开源编程语言(OpenSource Language):

JavaScript 97.4%

开源软件介绍(OpenSource Introduction):

gulp-version-number

Add version number to js/css/image in HTML

NPM version

usage

var version = require('gulp-version-number');

gulp.src('src/*.html')
    .pipe(version({
		... configuration ...
    }))
    .pipe(gulp.dest('build'));

configuration

config

{

    /**
     * Global version value
     * default: %MDS%
     */
    'value' : '%MDS%',

    /**
     * MODE: REPLACE
     * eg:
     *    'keyword'
     *    /regexp/ig
     *    ['keyword']
     *    [/regexp/ig, '%MD5%']]
     */
    'replaces' : [
    
        /**
         * {String|Regexp} Replace Keyword/Rules to global value (config.value)
         */
        '#{VERSION_REPlACE}#',
        
        /**
         * {Array}
         * Replace keyword to custom value
         * if just have keyword, the value will use the global value (config.value).
         */    
        [/#{VERSION_REPlACE}#/g, '%TS%']
    ],
    
    
    /**
     * MODE: APPEND
     * Can coexist and replace, after execution to replace
     */
    'append' : {
    
        /**
         * Parameter
         */
        'key' : '_v',
        
        /**
         * Whether to overwrite the existing parameters
         * default: 0 (don't overwrite)
         * If the parameter already exists, as a "custom", covering not executed.
         * If you need to cover, please set to 1
         */
        'cover' : 0,
        
        /**
         * Appended to the position (specify type)
         * {String|Array|Object}
         * If you set to 'all', will apply to all type, rules will use the global setting.
         * If an array or object, will use your custom rules.
         * others will passing.
         * 
         * eg:
         *     'js'
         *     ['js']
         *     {type:'js'}
         *     ['css', '%DATE%']
         */
        'to' : [
        
            /**
             * {String} Specify type, the value is the global value
             */
            'css',
            
            /**
             * {Array}
             * Specify type, keyword and cover rules will use the global 
             * setting, If you need more details, please use the object 
             * configure.
             *
             * argument 0 necessary, otherwise passing.
             * argument 1 optional, the value will use the global value
             */
              ['image', '%TS%'],
              
            /**
             * {Object}
             * Use detailed custom rules to replace, missing items will 
             * be taken in setting the global completion
             
             * type is necessary, otherwise passing.
             */
            {
                'type'  : 'js',
                'attr'  : ['src', 'custom-src'] // String or Array, undefined this will use default. css: "href", js: ...
                'key'   : '_v',
                'value' : '%DATE%',
                'cover' : 1,
                'files': ['build.js', /dependency.js/] // Array [{String|Regex}] of explicit files to append to
            }
        ]
    },
 
    /**
     * Output to config file
     */
    'output' : {
        'file' : 'version.json'
    }
}

Priority - Covering relations

  • {Object}config.append.to[x].type == {Array}config.append.to[x][0] == {String}config.append.to[x]
  • config.append.to[x].key > config.append.key
  • config.append.to[x].cover > config.append.cover
  • config.append.to[x].value == config.append.to[x][1] [ (IF cover is TRUE) > (ELSE) == config.replace[x][1] ] > config.value

Options

Version types

  • %DATE% date [YYYYMMDD]
  • %DT% date + time [YYYYMMDDHHIISS]
  • %TS% timestamp [INT10]
  • %TSM% timestamp(millisecond) [INT13]
  • %MD5% MD5(timestamp) [STRING32]
  • %MDS% MD5(MD5(timestamp) + salt) [STRING32]
  • {STRING} In addition to the above keywords, considered custom

Change log

= 0.2.0 =
  • Add a configure prop to "Object" model at "options.append.to", set the attribute what you want to match
append : {
 to : [
   '???': {
     ...,
     'attr': [...] // string or array
     ...
   },
   ...
 ]
}
= 0.1.4 =
  • Detailed description comment and readme.
  • Change salt to length 8
= 0.1.3 =
  • BUGFIX: css rules
= 0.1.2 =
  • Output function mounting, the version output to a file.
= 0.1.1 =
  • BUGFIX: regexp
= 0.1.0 =

I was born




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap