Skip to content

Instantly share code, notes, and snippets.

@Slauta
Created July 21, 2017 15:03
Show Gist options
  • Save Slauta/fe7c5f3a0a3e706bbdaacf34b329dd44 to your computer and use it in GitHub Desktop.
Save Slauta/fe7c5f3a0a3e706bbdaacf34b329dd44 to your computer and use it in GitHub Desktop.
Wiredrap min.js insert fixed
return gulp.src(BUILD_DIR+'/index.html')
.pipe(wiredep({
ignorePath: "../../"+APP_DIR,
bowerJson: require('./bower.json'),
exclude: [ /jquery/ ],
fileTypes: {
html: {
replace: {
js: function(filePath) {
var minFilePath = filePath.replace('.js', '.min.js');
if (fs.existsSync(process.cwd() + '/' + APP_DIR + minFilePath)) {
return '<script src="' + 'assets' + minFilePath + '?cache='+ CACHE_SLAYER +'"></script>';
} else {
return '<script src="' + 'assets' + filePath + '"></script>';
}
}
}
}
}
}))
.pipe(gulp.dest('./'+BUILD_DIR))
.pipe(browserSync.stream());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment