diff --git a/.eleventyignore b/.eleventyignore index e69de29..2f1fc3a 100644 --- a/.eleventyignore +++ b/.eleventyignore @@ -0,0 +1,2 @@ +README.md +resources/ diff --git a/_headers.txt b/_headers.txt new file mode 100644 index 0000000..68985e7 --- /dev/null +++ b/_headers.txt @@ -0,0 +1,5 @@ +/css/* + Cache-Control: public, max-age=14400 + +/img/* + Cache-Control: public, max-age=604800 diff --git a/package.json b/package.json index a31dcec..f897101 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "scripts": { "build": "eleventy", - "postbuild": "postcss _site/css/*.css -u autoprefixer cssnano -r --no-map", + "postbuild": "postcss _site/css/*.css -u autoprefixer cssnano -r --no-map && node resources/tooling/copy-files.js", "watch": "eleventy --watch", "serve": "eleventy --serve", "start": "eleventy --serve", diff --git a/resources/tooling/copy-files.js b/resources/tooling/copy-files.js new file mode 100644 index 0000000..104f264 --- /dev/null +++ b/resources/tooling/copy-files.js @@ -0,0 +1,31 @@ +const fs = require('fs'); +const path = require('path'); + +const files = [ + { + src: path.join( + __dirname, + '..', + '..', + '_headers.txt' + ), + dest: path.join( + __dirname, + '..', + '..', + '_site', + '_headers' + ), + }, +]; + +files.forEach((file) => { + let src = file.src; + let dest = file.dest; + if (fs.existsSync(src)) { + fs.copyFile(src, dest, function (err) { + if (err) throw err; + console.log(src, 'was copied to', dest); + }); + } +});