mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-21 11:09:30 -07:00
gulp publish caching changes
This commit is contained in:
@@ -12,11 +12,11 @@ import s3Upload from 'gulp-s3-upload';
|
|||||||
import webpack from 'webpack-stream';
|
import webpack from 'webpack-stream';
|
||||||
import TerserPlugin from 'terser-webpack-plugin';
|
import TerserPlugin from 'terser-webpack-plugin';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import reader from '../src/playlist-reader.mjs';
|
import file from 'gulp-file';
|
||||||
import file from "gulp-file";
|
|
||||||
|
|
||||||
// get cloudfront
|
// get cloudfront
|
||||||
import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront';
|
import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront';
|
||||||
|
import reader from '../src/playlist-reader.mjs';
|
||||||
|
|
||||||
const clean = () => deleteAsync(['./dist/**/*', '!./dist/readme.txt']);
|
const clean = () => deleteAsync(['./dist/**/*', '!./dist/readme.txt']);
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ const compressHtml = async () => {
|
|||||||
const otherFiles = [
|
const otherFiles = [
|
||||||
'server/robots.txt',
|
'server/robots.txt',
|
||||||
'server/manifest.json',
|
'server/manifest.json',
|
||||||
'server/music/**/*.mp3'
|
'server/music/**/*.mp3',
|
||||||
];
|
];
|
||||||
const copyOtherFiles = () => src(otherFiles, { base: 'server/', encoding: false })
|
const copyOtherFiles = () => src(otherFiles, { base: 'server/', encoding: false })
|
||||||
.pipe(dest('./dist'));
|
.pipe(dest('./dist'));
|
||||||
@@ -145,6 +145,7 @@ const upload = () => src(uploadSources, { base: './dist' })
|
|||||||
maps: {
|
maps: {
|
||||||
CacheControl: (keyname) => {
|
CacheControl: (keyname) => {
|
||||||
if (keyname.indexOf('index.html') > -1) return 'max-age=300'; // 10 minutes
|
if (keyname.indexOf('index.html') > -1) return 'max-age=300'; // 10 minutes
|
||||||
|
if (keyname.indexOf('.mp3') > -1) return 'max-age=31536000'; // 1 year for mp3 files
|
||||||
return 'max-age=2592000'; // 1 month
|
return 'max-age=2592000'; // 1 month
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -176,8 +177,8 @@ const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
|||||||
const buildPlaylist = async () => {
|
const buildPlaylist = async () => {
|
||||||
const availableFiles = await reader();
|
const availableFiles = await reader();
|
||||||
const playlist = { availableFiles };
|
const playlist = { availableFiles };
|
||||||
return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist'))
|
return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist'));
|
||||||
}
|
};
|
||||||
|
|
||||||
const buildDist = series(clean, parallel(buildJs, compressJsData, compressJsVendor, copyCss, compressHtml, copyOtherFiles, buildPlaylist));
|
const buildDist = series(clean, parallel(buildJs, compressJsData, compressJsVendor, copyCss, compressHtml, copyOtherFiles, buildPlaylist));
|
||||||
|
|
||||||
@@ -189,4 +190,4 @@ export default publishFrontend;
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
buildDist,
|
buildDist,
|
||||||
}
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user