diff --git a/README.md b/README.md index 492b4789..98e5b170 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,15 @@ Relevant files that need to retain their names are not moved: ## Installation -``` -npm install --save-dev netlify-plugin-hashfiles -``` - -Then add the following to your `netlify.yml`: +To install, add the following lines to your `netlify.toml` file: -```yml -plugins: - - type: netlify-plugin-hashfiles +```toml +[[plugins]] +package = "netlify-plugin-hashfiles" ``` +_The `[[plugins]]` line is required for each plugin, even if you have other plugins in your `netlify.toml` file already._ + **IMPORTANT NOTE:** Hashing files has to be the last thing you do before deploying. Make sure you add hashfiles at the bottom of your plugin configuration. ## Configuration @@ -40,22 +38,18 @@ Hashfiles works out of the box, but can be improved upon with some improved know These are the configuration options with their default values: -```yml -plugins: - - type: netlify-plugin-hashfiles - config: - # An array of glob patterns for pages on your site - # Recursive traversal will start from these - entryPoints: - - "*.html" - - # Directory where content-addressable files are moved - staticDir: /static/ - - # canonicalRoot is the origin where your page will eventually be deployed - # Setting canonicalRoot will enable hashfiles to map canonical URL's to your - # page in your code to local files on disk - canonicalRoot: https://your-page.netlify.com +```toml +[[plugins]] +package = "netlify-plugin-hashfiles" + + [plugins.inputs] + # An array of glob patterns for pages on your site. Recursive traversal will start from these + entryPoints = [ + "*.html" + ] + + # Directory where content-addressable files are moved and immutable cache-headers are set + staticDir = "/static/" ``` ## License diff --git a/lib/config.schema.json b/lib/config.schema.json deleted file mode 100644 index e76c6dd5..00000000 --- a/lib/config.schema.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "object", - "properties": { - "entryPoints": { - "title": "Entry points", - "description": "An array of glob patterns for pages on your site. Recursive traversal will start from these", - "type": "array", - "items": [ - { - "type": "string" - } - ], - "minItems": 1, - "uniqueItems": true, - "default": [ - "*.html" - ] - }, - "staticDir": { - "title": "Static files directory", - "description": "Directory where content-addressable files are moved and immutable ccache-headers are set", - "type": "string", - "default": "static" - } - }, - "additionalProperties": false -} diff --git a/lib/index.js b/lib/index.js index ef2c20c6..7ec426cc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,17 +4,12 @@ const appendFile = promisify(require('fs').appendFile); const deleteFile = promisify(require('fs').unlink); const AssetGraph = require('assetgraph'); const hashfiles = require('assetgraph-hashfiles'); -const configSchema = require('./config.schema.json'); const excludedRelationTypes = ['JavaScriptFetch']; const canonicalRoot = process.env.URL; module.exports = { - name: 'hashfiles', - - config: configSchema, - onPostBuild: async ({ constants: { BUILD_DIR }, pluginConfig: { entryPoints, staticDir }