add staging gulp tasks

This commit is contained in:
Matt Walsh
2025-06-26 22:30:42 -05:00
parent ef0b60a0b8
commit 5a80f43f30
2 changed files with 21 additions and 7 deletions

View File

@@ -163,9 +163,10 @@ const uploadSources = [
'!dist/images/**/*',
'!dist/fonts/**/*',
];
const upload = () => src(uploadSources, { base: './dist', encoding: false })
const uploadCreator = (bucket) => () => src(uploadSources, { base: './dist', encoding: false })
.pipe(s3({
Bucket: process.env.BUCKET,
Bucket: bucket,
StorageClass: 'STANDARD',
maps: {
CacheControl: (keyname) => {
@@ -181,10 +182,14 @@ const imageSources = [
'server/images/**',
'!server/images/gimp/**',
];
const uploadImages = () => src(imageSources, { base: './server', encoding: false })
const upload = uploadCreator(process.env.BUCKET);
const uploadPreview = uploadCreator(process.env.BUCKET_PREVIEW);
const uploadImagesCreator = (bucket) => () => src(imageSources, { base: './server', encoding: false })
.pipe(
s3({
Bucket: process.env.BUCKET,
Bucket: bucket,
StorageClass: 'STANDARD',
maps: {
CacheControl: () => 'max-age=31536000',
@@ -192,11 +197,14 @@ const uploadImages = () => src(imageSources, { base: './server', encoding: false
}),
);
const uploadImages = uploadImagesCreator(process.env.BUCKET);
const uploadImagesPreview = uploadImagesCreator(process.env.BUCKET_PREVIEW);
const copyImageSources = () => src(imageSources, { base: './server', encoding: false })
.pipe(dest('./dist'));
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
DistributionId: process.env.DISTRIBUTION_ID,
const invalidateCreator = (distributionId) => () => cloudfront.send(new CreateInvalidationCommand({
DistributionId: distributionId,
InvalidationBatch: {
CallerReference: (new Date()).toLocaleString(),
Paths: {
@@ -206,6 +214,9 @@ const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
},
}));
const invalidate = invalidateCreator(process.env.DISTRIBUTION_ID);
const invalidatePreview = invalidateCreator(process.env.DISTRIBUTION_ID_PREVIEW);
const buildPlaylist = async () => {
const availableFiles = await reader();
const playlist = { availableFiles };
@@ -217,10 +228,12 @@ const buildDist = series(clean, parallel(buildJs, buildWorkers, compressJsData,
// 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);
export default publishFrontend;
export {
buildDist,
invalidate,
stageFrontend,
};

View File

@@ -1,9 +1,10 @@
import updateVendor from './gulp/update-vendor.mjs';
import publishFrontend, { buildDist, invalidate } from './gulp/publish-frontend.mjs';
import publishFrontend, { buildDist, invalidate, stageFrontend } from './gulp/publish-frontend.mjs';
export {
updateVendor,
publishFrontend,
buildDist,
invalidate,
stageFrontend,
};