吞噬和注入path
在Visual Studio中,我有以下客户端项目结构
-wwwroot -app -js -views -css -images -lib index.html
随着gulp注入我想在index.html注入我的JavaScript的path:
gulp.task('injecttest', function () { var target = gulp.src('wwwroot/index.html'); var sources = gulp.src(['wwwroot/app/js/**/*.js'], { read: false }); return target.pipe(inject(sources)).pipe(gulp.dest('wwwroot/'));; });
gulpfile.js位于wwwroot目录之外。 这里的问题是,在我的index.html里,注入的forms是:
<script src="/wwwroot/app/js/RemoteCallServices.js"></script>
和我需要的工作
<script src="app/js/RemoteCallServices.js"></script>
我怎么能做到这一点?
你可以使用gulp -inject ignorePath选项
gulp.task('injecttest', function () { var target = gulp.src('wwwroot/index.html'); var sources = gulp.src(['wwwroot/app/js/**/*.js'], { read: false }); return target.pipe(inject(sources, { ignorePath: '/wwwrooot/')).pipe(gulp.dest('wwwroot/'));; });