mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 07:39:29 -07:00
add staging gulp tasks
This commit is contained in:
@@ -163,9 +163,10 @@ const uploadSources = [
|
|||||||
'!dist/images/**/*',
|
'!dist/images/**/*',
|
||||||
'!dist/fonts/**/*',
|
'!dist/fonts/**/*',
|
||||||
];
|
];
|
||||||
const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
|
||||||
|
const uploadCreator = (bucket) => () => src(uploadSources, { base: './dist', encoding: false })
|
||||||
.pipe(s3({
|
.pipe(s3({
|
||||||
Bucket: process.env.BUCKET,
|
Bucket: bucket,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
maps: {
|
maps: {
|
||||||
CacheControl: (keyname) => {
|
CacheControl: (keyname) => {
|
||||||
@@ -181,10 +182,14 @@ const imageSources = [
|
|||||||
'server/images/**',
|
'server/images/**',
|
||||||
'!server/images/gimp/**',
|
'!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(
|
.pipe(
|
||||||
s3({
|
s3({
|
||||||
Bucket: process.env.BUCKET,
|
Bucket: bucket,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
maps: {
|
maps: {
|
||||||
CacheControl: () => 'max-age=31536000',
|
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 })
|
const copyImageSources = () => src(imageSources, { base: './server', encoding: false })
|
||||||
.pipe(dest('./dist'));
|
.pipe(dest('./dist'));
|
||||||
|
|
||||||
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
const invalidateCreator = (distributionId) => () => cloudfront.send(new CreateInvalidationCommand({
|
||||||
DistributionId: process.env.DISTRIBUTION_ID,
|
DistributionId: distributionId,
|
||||||
InvalidationBatch: {
|
InvalidationBatch: {
|
||||||
CallerReference: (new Date()).toLocaleString(),
|
CallerReference: (new Date()).toLocaleString(),
|
||||||
Paths: {
|
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 buildPlaylist = async () => {
|
||||||
const availableFiles = await reader();
|
const availableFiles = await reader();
|
||||||
const playlist = { availableFiles };
|
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
|
// 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
|
// 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 publishFrontend = series(buildDist, uploadImages, upload, invalidate);
|
||||||
|
const stageFrontend = series(buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
|
||||||
|
|
||||||
export default publishFrontend;
|
export default publishFrontend;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
buildDist,
|
buildDist,
|
||||||
invalidate,
|
invalidate,
|
||||||
|
stageFrontend,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import updateVendor from './gulp/update-vendor.mjs';
|
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 {
|
export {
|
||||||
updateVendor,
|
updateVendor,
|
||||||
publishFrontend,
|
publishFrontend,
|
||||||
buildDist,
|
buildDist,
|
||||||
invalidate,
|
invalidate,
|
||||||
|
stageFrontend,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user