簡體   English   中英

在Gulp任務中更改bowerFiles()注入路徑

[英]Change bowerFiles() injection path in Gulp task

我有以下Gulp任務:

gulp.task('bowerinstall', function() {
    gulp.src('app/index.html')
        .pipe($.inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower'}))
        .pipe(gulp.dest(['dist/', 'app/']));
});

該任務查看我的index.html並將Bower文件注入其中。 效果很好,但是將以下路徑注入了我的index.html:

<script src="/app/bower_components/modernizr/modernizr.js"></script>

任務確定了要注入到我的應用程序中的正確資源很好,但是我希望它注入以下內容:

<script src="bower_components/modernizr/modernizr.js"></script>

有沒有辦法修改我的gulp任務來做到這一點?

謝謝!

在以下行中:

    .pipe($.inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower'}))

添加relative: true選項relative: true ,例如:

    .pipe($.inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower', relative: true}))

文檔中涵蓋了此內容: https : //www.npmjs.com/package/gulp-inject#injecting-files-relative-to-target-files

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM