Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加md5有问题 #2

Open
li9269391 opened this issue Apr 17, 2016 · 1 comment
Open

加md5有问题 #2

li9269391 opened this issue Apr 17, 2016 · 1 comment

Comments

@li9269391
Copy link

//将js加上10位md5,并修改html中的引用路径,该动作依赖build-js

gulp.task('md5:js', ['build-js'], function (done) {
     gulp.src('dist/js/*.js')
        .pipe(md5(10, 'dist/app/*.html'))
        .pipe(gulp.dest('dist/js'))
        .on('end', done);
});

如gulp 3次,dist文件夹会出现像下面一样
news-list_fcffee5ba9.js
news-list_fcffee5ba9_fcffee5ba9.js
news-list_fcffee5ba9_fcffee5ba9_fcffee5ba9.js

@Froguard
Copy link

Froguard commented Jul 15, 2016

楼上,我给你提供一种解决方法:
src中配置成数组,末尾元素配置成排除项,排除md5格式的文件

 gulp.task('md5:js', ['build-js'], function (done) {
      gulp.src([
             'dist/js/*.js',
             '!dist/js/*_??????????.js'//排除*_md5.js
         ])
         .pipe(md5(10, 'dist/app/*.html'))
         .pipe(gulp.dest('dist/js'))
         .on('end', done);
 });

备注:gulp支持的是伪正则,为什么说是“伪”,因为我尝试过写真正的正则表达式,失败了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants