Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benjaminrancourt/eleventy-plugin-files-minifier
An Eleventy plugin to automatically minify files
https://github.com/benjaminrancourt/eleventy-plugin-files-minifier
eleventy eleventy-plugin hacktoberfest minification sherby transform
Last synced: 3 months ago
JSON representation
An Eleventy plugin to automatically minify files
- Host: GitHub
- URL: https://github.com/benjaminrancourt/eleventy-plugin-files-minifier
- Owner: benjaminrancourt
- License: mit
- Created: 2020-10-12T14:05:43.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-15T09:53:33.000Z (over 1 year ago)
- Last Synced: 2024-09-29T15:46:30.469Z (3 months ago)
- Topics: eleventy, eleventy-plugin, hacktoberfest, minification, sherby, transform
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# eleventy-plugin-files-minifier
This plugin allows you to automatically **minify** files when builting with **[Eleventy](https://www.11ty.dev/)**.
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:
- [pretty-data](https://www.npmjs.com/package/pretty-data): `css`, `json`, `xml` and `webmanifest`
- [html-minifier](https://www.npmjs.com/package/html-minifier): `html` and `xsl`## Installation
Install the dependency with NPM:
```shell script
npm install @sherby/eleventy-plugin-files-minifier --save-dev
```Open up your Eleventy config file (probably `.eleventy.js`) and use `addPlugin`:
```javascript
const eleventyPluginFilesMinifier = require("@sherby/eleventy-plugin-files-minifier");
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
```## License
The [MIT License][1] (MIT)
[1]: https://opensource.org/licenses/MIT