An Eleventy plugin to automatically minify files
npm install @codestitchofficial/eleventy-plugin-minifycss, html, json, xml, xsl and webmanifest files.
css, json, xml and webmanifest
html and xsl
shell script
npm install @codestitchofficial/eleventy-plugin-minify --save-dev
`
Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:
`javascript
const eleventyPluginFilesMinifier = require("@codestitchofficial/eleventy-plugin-minify");
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(eleventyPluginFilesMinifier);
};
`
Usage
The plugin will automatically minify supported files, you don't need to do anything except the installation!
Make sure that the files you want to minify are currently written by Eleventy. If not, you can easily rename it and add
Front matter options. For example, for the manifest.webmanifest file, I could rename it as manifest.webmanifest.njk
and add the following code at his top:
`yaml
---
eleventyExcludeFromCollections: true
permalink: /manifest.webmanifest
---
`
Publish
Increment the version defined in the package.json file and run the command below to publish the module in the
registry:
`bash
Dry run
npm publish --dry-run
For real (are you really sure?)
npm publish --access public
``