@codestitchofficial/eleventy-plugin-minify

1.1.3 • Public • Published

eleventy-plugin-files-minifier

[!NOTE]
This plugin is a continuation of eleventy-plugin-files-minifier by Benjamin Rancourt. This repo was seemingly abandoned and left projects with an unresolvable npm vulnerability. All we've done is forked the repo, updated the dependencies, and maintained this repo going forward. All credit goes where it is due!

This plugin allows you to automatically minify files when builting with Eleventy. It currently supports css, html, json, xml, xsl and webmanifest files.

Why should you minify your files? Simply to reduce the data transfered between your hosting servers and your visitors, even if some of them maybe some bots.

Under the hood, this plugin use the following plugins to minify code:

Installation

Install the dependency with NPM:

npm install @codestitchofficial/eleventy-plugin-minify --save-dev

Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:

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:

---
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:

# Dry run
npm publish --dry-run

# For real (are you really sure?)
npm publish --access public

License

The MIT License (MIT)

Package Sidebar

Install

npm i @codestitchofficial/eleventy-plugin-minify

Weekly Downloads

21

Version

1.1.3

License

MIT

Unpacked Size

7.17 kB

Total Files

5

Last publish

Collaborators

  • itsethanh