Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Cache Busting via Regex and Gulp.js
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var replace = require('gulp-replace');
gulp.task('js', function () {
var filename = 'script' + getDate() + '.js';
return gulp.src('Admin/Default.aspx', { base: './' }) //must define base so I can overwrite the src file below. Per
.pipe(replace(/<script id=\"bundle\".*<\/script>/g, '<script id="bundle" src="/dist/' + filename + '"></script>')) //so find the script tag with an id of bundle, and replace its src.
.pipe(gulp.dest('./')); //Write the file back to the same spot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.