我正在创建Gulp任务,它将使用wiredep注入js和css。以下是如何注射。
<!-- bower:js -->
<script src="../bower_components/jquery/dist/jquery.js"></script>
<!-- inject:js -->
<script src="/public/js/config/app.js"></script>
<script src="/public/js/components/home-component.js"></script>
但我需要注入
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<!-- inject:js -->
<script src="public/js/config/app.js"></script>
<script src="public/js/components/home-component.js"></script>
我设法将../
替换为``
如何先忽略'/'
?
这是我尝试过的,但没有奏效。
Gulp任务在
之下gulp.task('index', function () {
var target = gulp.src('./public/index.html');
var sources = gulp.src(config.appjs.concat(config.appcss), {read: false});
return target.pipe(inject(sources))
.pipe(wiredep({
ignorePath: "../"
}))
// .pipe(wiredep({
// ignorePath: "/"
// }))
// .pipe(wiredep({
// ignorePath: "/(.*?)\\/"
// }))
// .pipe(wiredep(
// {
// fileTypes: {
// html: {
// replace: {
// js: '<script src="{{filePath}}"></script>',
// css: '<link rel="stylesheet" href="{{filePath}}">'
// }
// }
// }
// }))
.pipe(gulp.dest('./dev'))
.pipe(browserSync.stream());
});
和
gulp.task('js', function () {
return gulp.src('./public/js/**/*.js')
.pipe(wiredep({
ignorePath: '/',
addRootSlash: false
}))
.pipe(gulp.dest('./dev/public/js'));
});