Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function doRevision() {
return gulp
.src([path.join(conf.paths.distPre, '**'), '!**/assets/**/*'])
// Do not update references other than in index.html. Do not rev index.html itself.
.pipe(revAll.revision(
{dontRenameFile: ['index.html'], dontSearchFile: [/^(?!.*index\.html$).*$/]}))
.pipe(gulp.dest(conf.paths.distRoot));
}
dontUpdateReference: ['.html'],
includeFilesInManifest: ['.css', '.js', '.html', 'htm'],
transformFilename: function (file, hash) {
var ext = path.extname(file.path);
// if(ext === '.html'){
// return path.basename(file.path, ext) + ext;
// }
return path.basename(file.path, ext) + '.' + hash.substr(0, 8) + ext;
}
};
if (config['reversion']) {
return gulp.src(['./tmp/**/*'])
.pipe(RevAll.revision(RevOptions))
.pipe(gulp.dest(paths.tmp.dir))
.pipe(revDel({
exclude: /(.html|.htm)$/
}))
.pipe(RevAll.manifestFile())
.pipe(gulp.dest(paths.tmp.dir));
} else {
cb();
}
}
path.join(distPath, "webfonts", "*"),
// Cachebust our JS files and the source maps for them.
path.join(distPath, "js", "*.js"),
path.join(distPath, "js", "*.map"),
// Cachebust our vendored JS files and the source maps for them.
path.join(distPath, "js", "vendor", "*.js"),
path.join(distPath, "js", "vendor", "*.map"),
// Cachebust our Image files.
path.join(distPath, "images", "*"),
];
return gulp.src(paths, { base: distPath })
.pipe(manifest.revision({
fileNameManifest: "manifest.json",
includeFilesInManifest: [
".css",
".map",
".woff",
".woff2",
".svg",
".eot",
".ttf",
".otf",
".png",
".jpg",
".ico",
".js",
],
}))
gulp.task('dist-rev-assets', function() {
const revAll = RevAll.revision({
dontRenameFile: [
'.json',
'favicon.ico',
/static\/addon\/*/,
/static\/locales\/*/,
/static\/images\/experiments\/[^]*\/social\/*/,
'.html',
'.rss',
'.atom'
],
dontUpdateReference: [
/static\/addon\/*/,
/static\/locales\/*/,
/.*\.json/,
/static\/images\/experiments\/[^]*\/social\/*/,
'favicon.ico',
gulp.task("hash", done => {
gulp
.src("dist/**")
.pipe(
gulpIf('*.js',uglify())
)
.pipe(
gulpIf(isImage, imagemin())
)
.pipe(
RevAll.revision({
dontRenameFile: [/\.html$/]
})
)
.pipe(revdel({
exclude: function (file) {
if (/\.html$/.test(file.name)) {
return true; //if you want to exclude the file from being deleted
}
}
}))
.pipe(gulp.dest("dist"))
done();
});
gulp.task('revision:append', () => {
return gulp.src(`${paths.dist.root}/**/*`)
.pipe(RevAll.revision({dontRenameFile: [/^\/favicon.ico$/g, '.html']}))
.pipe(gulp.dest(root.tmp))
})
gulp.task('assets', function () {
let revAllOpts = {
dontGlobal: ['.ico', 'fira.css', 'javascript-logo.png'],
dontRenameFile: ['.ico', '.html', /fonts/],
dontSearchFile: ['.js'],
debug: false,
}
return gulp.src('./app/**/*')
.pipe(RevAll.revision(revAllOpts))
.pipe(gulp.dest('build'))
})
function bustCaches() {
return src(['./dist/**'])
.pipe(
RevAll.revision({
dontRenameFile: [/^\/favicon.ico$/g, '.html'],
dontUpdateReference: [/^\/favicon.ico$/g, '.html'],
}),
)
.pipe(dest('./dist'))
.on('end', () => {
gutil.beep();
gutil.log(filesGenerated);
gutil.log(thankYou);
});
}
gulp.task('revision', () => {
return gulp
.src('public/**')
.pipe(RevAll.revision(revisionOpts))
.pipe(gulp.dest('tmp'))
})