gulp版本號修改


 新版插件修改無效時,可以使用以下版本:

{
  "gulp-rev": "7.1.2",
  "gulp-rev-collector": "1.0.5"
}

默認效果:

<link rel="stylesheet" href="css/app-803a7fe4ae.css">
<script src="js/app-3a0d844594.js"></script>

預期效果:

<link rel="stylesheet" href="css/app.css?v=803a7fe4ae">
<script src="js/app.js?v=3a0d844594"></script>
 

為了將 gulp-rev + gulp-rev-collector 添加版本號后的默認效果修改為預期效果,需作如下修改:

1.打開node_modules\gulp-rev\index.js
manifest[originalFile] = revisionedFile;
更改為: 
manifest[originalFile] = originalFile + '?v=' + file.revHash;
 
2.打開nodemodules\rev-path\index.js
return filename + '-' + hash + ext;
更改為: 
return filename + ext;
 
3.打開node_modules\gulp-rev-collector\index.js
if ( !_.isString(json[key]) || path.basename(json[key]).replace(new RegExp( opts.revSuffix ), '' ) !== path.basename(key) ) { 
更改為: 
if ( !_.isString(json[key]) || path.basename(json[key]).split('?')[0] !== path.basename(key) ) {
regexp: new RegExp( '([\/\\\\\'"])' + pattern, 'g' ),
更改為: 
regexp: new RegExp( '([\/\\\\\'"])' + pattern+'(\\?v=\\w{10})?', 'g' ),


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM