2022-07-19 14:25:29 +00:00
const eleventySass = require ( "eleventy-sass" ) ;
2022-09-19 10:43:19 +00:00
const lazyImagesPlugin = require ( 'eleventy-plugin-lazyimages' ) ;
2022-10-11 15:44:21 +00:00
const faviconPlugin = require ( "eleventy-favicon" ) ;
2022-10-24 12:17:02 +00:00
// https://github.com/artstorm/eleventy-plugin-seo
2022-10-11 15:44:21 +00:00
const pluginSEO = require ( "eleventy-plugin-seo" ) ;
2022-07-19 14:25:29 +00:00
2022-10-24 12:17:02 +00:00
// https://github.com/saneef/eleventy-plugin-img2picture
2022-10-07 13:37:57 +00:00
const img2picture = require ( "eleventy-plugin-img2picture" ) ;
// https://www.npmjs.com/package/@sardine/eleventy-plugin-tinycss
const tinyCSS = require ( '@sardine/eleventy-plugin-tinycss' ) ;
// https://www.npmjs.com/package/@sardine/eleventy-plugin-tinysvg
const tinysvg = require ( '@sardine/eleventy-plugin-tinysvg' ) ;
// https://www.npmjs.com/package/@sardine/eleventy-plugin-tinyhtml
const tinyHTML = require ( '@sardine/eleventy-plugin-tinyhtml' ) ;
2022-07-19 14:25:29 +00:00
module . exports = function ( eleventyConfig ) {
eleventyConfig . addPassthroughCopy ( 'src/assets/fonts' ) ;
eleventyConfig . addPassthroughCopy ( "./src/assets/js" ) ;
2022-10-07 13:37:57 +00:00
2022-10-24 12:17:02 +00:00
if ( process . env . ELEVENTY _ENV === "enable-image-optim" ) {
// img2picture (recommend not enabling)
////// this plugin smartly optimizes images on build, such as converting pngs to smaller jpegs.
////// did not see noticable speed gains when enabled, but it did cause rendering issues on older versions of Safari (e.g. on Calalina).
////// specifially, jpeg masking (as a replacement for alpha pngs) doesn't seem to work for all browsers.
2022-10-07 13:37:57 +00:00
eleventyConfig . addPlugin ( img2picture , {
// Should be same as Eleventy input folder set using `dir.input`.
eleventyInputDir : "src" ,
// Output folder for optimized images.
imagesOutputDir : "_site/assets/images" ,
// URL prefix for images src URLS.
// It should match with path suffix in `imagesOutputDir`.
// Eg: imagesOutputDir with `_site/images` likely need urlPath as `/images/`
urlPath : "/assets/images/" ,
2022-10-24 12:17:02 +00:00
sharpPngOptions : { pallette : true } ,
sharpJpegOptions : { quality : 100 }
2022-10-07 13:37:57 +00:00
} ) ;
} else {
// During development, copy the files to Eleventy's `dir.output`
2022-10-22 16:17:56 +00:00
eleventyConfig . addPassthroughCopy ( './src/assets/images/' ) ;
2022-10-07 13:37:57 +00:00
}
2022-07-19 14:25:29 +00:00
//plugins
eleventyConfig . addPlugin ( eleventySass ) ;
2022-10-11 15:44:21 +00:00
eleventyConfig . addPlugin ( faviconPlugin , { destination : './_site' } ) ;
eleventyConfig . addPlugin ( pluginSEO , require ( "./src/_data/seo.json" ) ) ;
2022-10-24 12:17:02 +00:00
//eleventyConfig.addPlugin(tinyCSS); // smartly injects selectors from external css files into style tags. requires some massaging. not ready for prime time.
2022-10-07 13:37:57 +00:00
eleventyConfig . addPlugin ( tinyHTML ) ;
eleventyConfig . addPlugin ( tinysvg , {
2022-10-21 08:51:39 +00:00
baseUrl : 'src/_includes/svgs/' ,
2022-10-07 13:37:57 +00:00
} ) ;
2022-07-19 14:25:29 +00:00
return {
dir : { input : "src" , output : "_site" , data : "_data" } ,
} ;
2022-10-24 12:17:02 +00:00
} ;