Dan Van Brunt
10/07/2021, 5:25 PMfileOptions
works in StaticSite
since exclude
and include
are setup as static properties (where includes always override excludes) there is no way to reproduce this command that the s3 sync CLI could…
aws s3 sync ./public/ "s3://${BUCKET_NAME}/" \
--exclude "*" \
--include "static/*" \
--include "*.css" \
--include "*.js" \
--exclude "sw.js" \
--cache-control 'public,max-age=31536000,immutable' --delete
Notice the second exclude
comes after a bunch of includes and another exclude. Perhaps laying out these fileOptions would have been better this way…
{
fileOptions: [
{
matching: [
{ exclude: '*' },
{ include: 'static/*' },
{ include: '*.css' },
{ include: '*.js' },
{ exclude: 'sw.js' },
],
cacheControl: 'public,max-age=31536000,immutable',
},
],
}
Dan Van Brunt
10/07/2021, 5:35 PM{
fileOptions: [
{
matching: [ '!*', 'static/*', '*.css', '*.js', '!sw.js'],
cacheControl: 'public,max-age=31536000,immutable',
},
],
}
Need to check that it doesn’t conflict with other !
in standard rules… but it appears you have to use [!thingy]
if you want to use negate.Dan Van Brunt
10/07/2021, 5:36 PMDan Van Brunt
10/07/2021, 5:39 PMDan Van Brunt
10/07/2021, 5:43 PMexclude
is also missing. which is a perfectly acceptable command with the CLI.
aws s3 sync ./public/ "s3://${BUCKET_NAME}/" \
--exclude "*.html" \
--exclude "page-data/*.json" \
--exclude "*.js" \
--exclude "*.css" \
--exclude "static/*" \
--exclude "robot.txt" \
--exclude "sitemap.xml" \
--delete
Dan Van Brunt
10/07/2021, 5:53 PMFrank
Frank
aws s3 sync ./public/ "s3://${BUCKET_NAME}/" \
--exclude "*" \
--include "static/*" \
--include "*.css" \
--include "*.js" \
--exclude "sw.js" \
--cache-control 'public,max-age=31536000,immutable' --delete
Dan Van Brunt
10/07/2021, 8:50 PMDan Van Brunt
10/07/2021, 8:51 PMsw.js
gets uploaded twice.Dan Van Brunt
10/07/2021, 8:51 PMFrank