shonny-ua / gulp-rev-collector

Static asset revision data collector from manifests, with was generated from different streams and replace they's links in html template.
MIT License
149 stars 41 forks source link

How can gulp match template variable like ${x} in files paths when use gulp-rev to add md5? #28

Closed xingxiaoyiyio closed 8 years ago

xingxiaoyiyio commented 8 years ago

All my pages are .jsp format, I import static js&css resources like below:

<link rel="stylesheet" type="text/css" href="${url_resources}/css/commQuery/commQuery.css">
<script type="text/javascript" src="${url_resources}/js/jquery.min.js"></script>

When I use gulp-rev && gulp-rev-collector to add md5(version No.) for these resources, it doesn't work since the path include ${url_resources}, is there any way to set this ${url_resources} template variable?

shonny-ua commented 8 years ago

Ypu can use gulp-rev-collector's dirReplacements option. Like below:

gulp.task('rev', function () {
    return gulp.src(['rev/**/*.json', 'templates/**/*.html'])
        .pipe( revCollector({
            dirReplacements: {
                '${url_resources}/css/commQuery/': '/path_to_url_resources/css/commQuery/',
                '${url_resources}/js/': '/path_to_url_resources/js/'
            }
        }) )
        .pipe( minifyHTML({
                empty:true,
                spare:true
            }) )
        .pipe( gulp.dest('dist') );
});
shonny-ua commented 8 years ago

Can I close Your issue?

xingxiaoyiyio commented 8 years ago

Ok !

在 2016年9月19日,下午3:42,Oleksandr Ovcharenko notifications@github.com 写道:

Can I close Your issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shonny-ua/gulp-rev-collector/issues/28#issuecomment-247928671, or mute the thread https://github.com/notifications/unsubscribe-auth/ARE_bkXZwyDR-eq-QmuI61q7TC5DENUEks5qrjzugaJpZM4J-veO.