From 093b6ac239ff701bad3a4eb80e6da225b4523625 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Thu, 4 Sep 2025 21:57:12 -0500 Subject: [PATCH] unique version numbers for staging uploads --- gulp/publish-frontend.mjs | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/gulp/publish-frontend.mjs b/gulp/publish-frontend.mjs index 6293480..ee5b9c0 100644 --- a/gulp/publish-frontend.mjs +++ b/gulp/publish-frontend.mjs @@ -97,23 +97,27 @@ const copyCss = () => src(cssSources) const htmlSources = [ 'views/*.ejs', ]; -const compressHtml = async () => { - const packageJson = await readFile('package.json'); - const { version } = JSON.parse(packageJson); - - return src(htmlSources) - .pipe(ejs({ - production: version, - serverAvailable: false, - version, - OVERRIDES, - query: {}, - })) - .pipe(rename({ extname: '.html' })) - .pipe(htmlmin({ collapseWhitespace: true })) - .pipe(dest('./dist')); +const packageJson = await readFile('package.json'); +let { version } = JSON.parse(packageJson); +const previewVersion = async () => { + // generate a relatively unique timestamp for cache invalidation of the preview site + const now = new Date(); + const msNow = now.getTime() % 1_000_000; + version = msNow.toString(); }; +const compressHtml = async () => src(htmlSources) + .pipe(ejs({ + production: version, + serverAvailable: false, + version, + OVERRIDES, + query: {}, + })) + .pipe(rename({ extname: '.html' })) + .pipe(htmlmin({ collapseWhitespace: true })) + .pipe(dest('./dist')); + const otherFiles = [ 'server/robots.txt', 'server/manifest.json', @@ -205,7 +209,7 @@ const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyCss, com // upload_images could be in parallel with upload, but _images logs a lot and has little changes // by running upload last the majority of the changes will be at the bottom of the log for easy viewing const publishFrontend = series(buildDist, uploadImages, upload, invalidate); -const stageFrontend = series(buildDist, uploadImagesPreview, uploadPreview, invalidatePreview); +const stageFrontend = series(previewVersion, buildDist, uploadImagesPreview, uploadPreview, invalidatePreview); export default publishFrontend;