Tom
Tom

Reputation: 4097

Gulp and injected path

in visual studio i have the following client side project struture

-wwwroot
   -app
      -js
      -views
   -css
   -images
   -lib
   index.html

With gulp-inject i want inject the path of my javascript inside the index.html:

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/'));;
});

The gulpfile.js is outside the wwwroot directory. The problem here is that inside my index.html, the injected are in the form of:

<script src="/wwwroot/app/js/RemoteCallServices.js"></script>

and to work i need to have

<script src="app/js/RemoteCallServices.js"></script>

How can i achieve that?

Upvotes: 1

Views: 84

Answers (1)

grimurd
grimurd

Reputation: 2850

You can use the gulp-inject ignorePath option

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/'));;
});

Upvotes: 1

Related Questions