这是我的项目
- Project root
|- build
|-css
|-js
|-index.html
|- src
|- css
|- js
|-index.html
|-gulpfile.js
我使用 gulp 并希望将 build/scc 和 build/js 文件注入 src/index.html 并将其放置为 build/index.html
这样做:
gulp.task('index', function () {
var target = gulp.src('src/index.html');
var sources = gulp.src(['build/js/*.js', 'build/styles/*.css'], { ignorePath: 'build/', addRootSlash: false });
return target.pipe(inject(sources))
.pipe(gulp.dest('build'));
});
我需要跳过 '/build/' 部分但仍然在 html 文件的输出中显示:
<link rel="stylesheet" href="/build/styles/app.min.css">
<script src="/build/js/app.min.js"></script>