gulp-rev-replace不会更改我的master.blade.php中的修订文件名

我一直在尝试在Laravel项目中使用gulp来创build一个构build系统,现在唯一的问题是在我的master.blade.php文件中重命名正确的文件名。 现在,它只跟随在gulp-useref参数中提供的文件名,但是由gulp-useref gulp-rev修订的文件不会被gulp-rev-replace

这是我的g task任务:

 gulp.task('build', ['clean', 'scss', 'js', 'master'], function() { var assets, jsFilter = $.filter('**/*.js'), cssFilter = $.filter('**/*.css'); return gulp.src('app/views/layouts/master.blade.php') .pipe(assets = $.useref.assets({searchPath: '/'})) .pipe(jsFilter) .pipe($.uglify()) .pipe(jsFilter.restore()) .pipe(cssFilter) .pipe($.csso()) .pipe(cssFilter.restore()) .pipe($.rev()) .pipe(assets.restore()) .pipe($.useref()) .pipe($.revReplace()) .pipe($.rename(function(path) { if(path.extname === '.php') { path.dirname = 'app/views/layouts'; } else { path.dirname = 'public/assets'; } })) .pipe(gulp.dest('./')) .pipe($.size({title: 'build files', showFiles: true})) .on('end', function() { setTimeout(function() { // force watchify to close all watchers process.exit(); }); }); }); 

默认的master.blade.php看起来像这样:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{$title}}</title> <!-- build:css assets/index.css --> <!-- bower:css --> <link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.css" /> <!-- endbower --> <link rel="stylesheet" href="/.tmp/index.css"> <!-- endbuild --> </head> <body> <section id="container"> <header> @include('layouts.navbar') </header> <aside> @include('layouts.sidebar') </aside> <section> @yield('content') </section> <footer> @include('layouts.footer') </footer> </section> <!-- build:js assets/index.js --> <!-- bower:js --> <script src="/bower_components/jquery/dist/jquery.js"></script> <script src="/bower_components/lodash/dist/lodash.compat.js"></script> <!-- endbower --> <script src="/.tmp/index.js"></script> <!-- endbuild --> </body> </html> 

尽pipe使用了gulp-rev-replacepipe道,结果总是如此。

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{$title}}</title> <link rel="stylesheet" href="assets/index.css"> </head> <body> <section id="container"> <header> @include('layouts.navbar') </header> <aside> @include('layouts.sidebar') </aside> <section> @yield('content') </section> <footer> @include('layouts.footer') </footer> </section> <script src="assets/index.js"></script> </body> </html> 

我想出了这个问题, gulp-rev-replace文档提到,默认情况下,它们只replace扩展名为['.js', '.css', '.html', '.hbs']的文件。 通过在replaceInExtensions选项中传递['.php']。