├── .npmignore ├── .gitignore ├── manifest.yml ├── package.json ├── index.js └── README.md /.npmignore: -------------------------------------------------------------------------------- 1 | .netlify 2 | node_modules 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local Netlify folder 2 | .netlify 3 | node_modules 4 | .idea 5 | -------------------------------------------------------------------------------- /manifest.yml: -------------------------------------------------------------------------------- 1 | name: netlify-plugin-jekyll-cache 2 | inputs: 3 | - name: jekyllSource 4 | description: The Jekyll source directory 5 | default: '.' 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "netlify-plugin-jekyll-cache", 3 | "version": "1.0.0", 4 | "description": "Persist the Jekyll cache between Netlify builds", 5 | "main": "index.js", 6 | "repository": "https://github.com/Mesomorphic/netlify-plugin-jekyll-cache.git", 7 | "keywords": [ 8 | "netlify", 9 | "netlify-plugin", 10 | "jekyll" 11 | ], 12 | "author": { 13 | "name": "Matthew Simpson", 14 | "email": "matthew@mesomorphic.co.uk", 15 | "url": "https://www.mesomorphic.co.uk" 16 | }, 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/Mesomorphic/netlify-plugin-jekyll-cache/issues" 20 | }, 21 | "homepage": "https://github.com/Mesomorphic/netlify-plugin-jekyll-cache#readme" 22 | } 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const cacheDir = (constants, jekyllSource) => [ 2 | constants.PUBLISH_DIR, 3 | `${jekyllSource}/.jekyll-cache`, 4 | ]; 5 | 6 | module.exports = { 7 | async onPreBuild({ constants, inputs, utils }) { 8 | if (await utils.cache.restore(cacheDir(constants, inputs.jekyllSource))) { 9 | console.log('Restoring Jekyll cache'); 10 | } else { 11 | console.log('No Jekyll cache found. Skipping'); 12 | } 13 | }, 14 | async onPostBuild({ constants, inputs, utils }) { 15 | if (await utils.cache.save(cacheDir(constants, inputs.jekyllSource))) { 16 | console.log('Jekyll cache stored'); 17 | } else { 18 | console.log('Jekyll cache was not found. Please check your config for this plugin'); 19 | } 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Netlify Build Plugin: Persist the Jekyll Cache between builds 2 | 3 | Speed up deploys by caching your previous build cache, so you only need to build changed files (and any other cached assets) 4 | 5 | ## Installation 6 | 7 | You can install this plugin directly via the Netlify UI [here](https://app.netlify.com/teams/madhatter2099/plugins/netlify-plugin-jekyll-cache/install). 8 | 9 | If you don't want to use the UI then you can install the plugin using npm. Add the plugin as a development dependency: 10 | 11 | ``` 12 | npm install -D netlify-plugin-jekyll-cache 13 | ``` 14 | OR 15 | ``` 16 | yarn add --dev netlify-plugin-jekyll-cache 17 | ``` 18 | 19 | ## Configuration 20 | 21 | Add the following to your `netlify.toml`: 22 | 23 | ``` 24 | [[plugins]] 25 | package = "netlify-plugin-jekyll-cache" 26 | 27 | [plugins.inputs] 28 | 29 | # This is only required if you have defined a source directory in Jekyll 30 | # At some point this will become automated, but for now it must be specified 31 | jekyllSource = "/jekyll" 32 | ``` 33 | --------------------------------------------------------------------------------