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O,EAAC,IAGlB,EAAO,sBACT,GAAG,WACD,GAAG,EAAU,uBACb,eAAe,IACd,IACC,GAAI,EAAK,MAAM,EACf,QAAQ,IAAI,oBAAmB,KAKrC,QAAQ,IAAI,qCAEhB","file":"/npm/netlify-plugin-11ty@1.5.0/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/netlify-plugin-11ty@1.5.0/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const path = require('path')\nconst fs = require('fs')\n\nconst getCacheDirs__ = (base, input) => {\n  let cacheDirs = []\n\n  if (!input) return []\n\n  if (typeof input === 'string') {\n    cacheDirs.push(path.normalize(base + '/' + input))\n  } else if (Array.isArray(input)) {\n    input.map((x) => {\n      cacheDirs.push(path.normalize(base + '/' + x))\n    })\n  } else {\n    console.log(`Warning: Unsupported value in inputs. Ignoring ${input}`)\n  }\n\n  return cacheDirs\n}\n\nconst getCacheDirs = (base, inputs) => {\n  return [\n    ...getCacheDirs__(base, inputs.cache_img),\n    ...getCacheDirs__(base, inputs.cache_assets),\n    ...getCacheDirs__(base, inputs.cache_other),\n  ]\n}\n\nconst getHttpHeaders = (inputs) => {\n  let httpHeader = ''\n\n  getCacheDirs__('.', inputs.cache_img).map((x) => {\n    httpHeader += `\n/${x}/*\n  cache-control: public\n  cache-control: max-age=31536000\n  cache-control: immutable\n\n`\n  })\n\n  return httpHeader\n}\n\nmodule.exports = {\n  async onPreBuild({ constants, inputs, utils }) {\n    if (!constants.PUBLISH_DIR || process.cwd() === constants.PUBLISH_DIR) {\n      utils.build.failBuild(\n        `11ty sites must publish the dist directory, but your site’s publish directory is set to : “${constants.PUBLISH_DIR}”. Please set your publish directory to your 11ty site’s dist directory.`,\n      )\n    }\n\n    const cacheDirs = getCacheDirs(constants.PUBLISH_DIR, inputs)\n    cacheDirs.map((x) => {\n      if (fs.existsSync(x)) {\n        console.log(\n          `Warning: directory ${x} already exists before restoring caches. It will be replaced if it exists in the cache.`,\n        )\n      }\n\n      if (path.normalize(x) === path.normalize(constants.PUBLISH_DIR)) {\n        console.log(\n          `11ty sites must publish the dist directory, but your site’s publish directory is set to : “${constants.PUBLISH_DIR}”.`,\n        )\n      }\n    })\n\n    if (await utils.cache.restore(cacheDirs)) {\n      console.log('Restoring 11ty directories from cache:')\n      cacheDirs.map((x) => {\n        console.log('- ' + x)\n      })\n    } else {\n      console.log('No 11ty caches found. Building fresh.')\n    }\n  },\n\n  async onPostBuild({ constants, inputs, utils }) {\n    const cacheDirs = getCacheDirs(constants.PUBLISH_DIR, inputs)\n\n    if (await utils.cache.save(cacheDirs)) {\n      console.log('Saving 11ty directories to cache:')\n      cacheDirs.map((x) => {\n        console.log('- ' + x)\n      })\n\n      if (inputs.cache_img_httpHeader) {\n        fs.appendFile(\n          `${constants.PUBLISH_DIR}/_headers`,\n          getHttpHeaders(inputs),\n          (err) => {\n            if (err) throw err\n            console.log('Saved http header')\n          },\n        )\n      }\n    } else {\n      console.log('Did not save any folders to cache.')\n    }\n  },\n}\n"]}