I am writing a gulp task to replace the local links of libraries used in development to be replaced with public CDN links. This is the part of my index.html file.
<script src="../bower_components/jquery/dist/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
Gulp task that I am writing is using gulp-cdnizer
gulp.task('cdn', function () {
return gulp.src('.tmp/serve/index.html')
.pipe(cdnizer([
'google:angular',
'cdnjs:jquery'
]))
.pipe(gulp.dest('dist'));
});
It should generate following output
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script>if(!(window.jQuery)) cdnizerLoad("bower_components/jquery/dist/jquery.js");</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script><script>if(!(window.angular)) cdnizerLoad("bower_components/angular/angular.js");</script>
But it work's only when I remove the leading '../' from the links added in input HTML file
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
What changes do I need to make in gulp cdn task to achieve the desired result with previous HTML input.
Edit
Folder structure is like this.