mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-13 23:29:36 -07:00
add staging gulp tasks
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user