You've already forked netlify-plugin-cache
mirror of
https://github.com/jakejarvis/netlify-plugin-cache.git
synced 2025-06-27 16:25:40 -04:00
provide a default 'paths', needed to list in Netlify UI (closes #1)
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
# netlify-plugin-cache
|
# Netlify Plugin: Custom Cache
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/netlify-plugin-cache)
|
[](https://www.npmjs.com/package/netlify-plugin-cache)
|
||||||
|
|
||||||
@ -18,7 +18,9 @@ package = "netlify-plugin-cache"
|
|||||||
paths = ["resources", "_vendor", "folder/file.md"]
|
paths = ["resources", "_vendor", "folder/file.md"]
|
||||||
```
|
```
|
||||||
|
|
||||||
This plugin only takes one input (which is required) named `paths`, an array of paths to files and/or folders relative to your project's root. These files/folders are restored before a build and saved in cache after a build **if it is successful**.
|
This plugin only takes one input named `paths`, an array of files and/or directories relative to your project's root. These files/directories are restored before a build and saved in cache after a build **if it is successful**.
|
||||||
|
|
||||||
|
**🚨 Important:** `paths` defaults to `[".cache"]`, but it's **highly recommended** you set this yourself based on the tools you're using. See examples below.
|
||||||
|
|
||||||
Read more about plugin configuration at [the official Netlify Plugin docs](https://docs.netlify.com/configure-builds/build-plugins/#install-a-plugin).
|
Read more about plugin configuration at [the official Netlify Plugin docs](https://docs.netlify.com/configure-builds/build-plugins/#install-a-plugin).
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ You can add their debug plugin **after** this plugin in your `netlify.toml`. (An
|
|||||||
package = "netlify-plugin-debug-cache"
|
package = "netlify-plugin-debug-cache"
|
||||||
```
|
```
|
||||||
|
|
||||||
The plugin will generate a file named `cache-output.json` at the root of your project's publish directory. [Learn more about this plugin here.](https://github.com/netlify-labs/netlify-plugin-debug-cache)
|
The plugin will generate a file named `cache-output.json` at the root of your project's publish directory. [See an example file](https://gist.github.com/jakejarvis/dff606289e8b5d6be42d317e425bbee6#file-cache-output-json) or [learn more about this plugin](https://github.com/netlify-labs/netlify-plugin-debug-cache).
|
||||||
|
|
||||||
## Licenses
|
## Licenses
|
||||||
|
|
||||||
|
7
index.js
7
index.js
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
const files = await cache.list(inputs.paths)
|
const files = await cache.list(inputs.paths)
|
||||||
console.log(`Successfully restored: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
|
console.log(`Successfully restored: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
|
||||||
} else {
|
} else {
|
||||||
console.log(`A cache of ${inputs.paths.join(', ')} doesn't exist (yet).`)
|
console.log(`A cache of '${inputs.paths.join(', ')}' doesn't exist (yet).`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -24,7 +24,10 @@ module.exports = {
|
|||||||
text: `${inputs.paths.join(', ')}`,
|
text: `${inputs.paths.join(', ')}`,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log(`Failed caching ${inputs.paths.join(', ')}. :(`)
|
// this probably happened because the default `paths` is set, so provide instructions to fix
|
||||||
|
console.log(`Attempted to cache: ${inputs.paths.join(', ')} ... but failed. :(`)
|
||||||
|
console.log(`Try setting the 'paths' input appropriately in your netlify.toml or netlify.yml.`)
|
||||||
|
console.log(`More details: https://jrvs.io/netlify-cache-usage`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@ name: netlify-plugin-cache
|
|||||||
inputs:
|
inputs:
|
||||||
- name: paths
|
- name: paths
|
||||||
description: Array of files and/or directories to cache between builds.
|
description: Array of files and/or directories to cache between builds.
|
||||||
required: true
|
default: [".cache"]
|
||||||
|
Reference in New Issue
Block a user