Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hacdias/caddy-v1-minify
:page_facing_up: Caddy plugin that provides file minification
https://github.com/hacdias/caddy-v1-minify
caddy caddy-plugin minify
Last synced: about 1 month ago
JSON representation
:page_facing_up: Caddy plugin that provides file minification
- Host: GitHub
- URL: https://github.com/hacdias/caddy-v1-minify
- Owner: hacdias
- License: apache-2.0
- Archived: true
- Created: 2016-06-08T09:22:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T18:35:14.000Z (over 4 years ago)
- Last Synced: 2024-11-17T12:15:46.209Z (about 2 months ago)
- Topics: caddy, caddy-plugin, minify
- Language: Go
- Homepage: https://caddyserver.com/docs/http.minify
- Size: 61.5 KB
- Stars: 40
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# minify
> ⚠️ This plugin is no longer maintained, nor is it compatible with Caddy 2+.
[![CircleCI branch](https://img.shields.io/circleci/project/github/hacdias/caddy-minify/master.svg?style=flat-square)](https://circleci.com/gh/hacdias/caddy-minify)
[![community](https://img.shields.io/badge/community-forum-ff69b4.svg?style=flat-square)](https://caddy.community)
[![Go Report Card](https://goreportcard.com/badge/github.com/hacdias/caddy-minify?style=flat-square)](https://goreportcard.com/report/hacdias/caddy-minify)Caddy plugin that implements minification on-the-fly for CSS, HTML, JSON, SVG and XML. It uses [tdewolff's library](https://github.com/tdewolff/minify) so, let's thank him! You can download this plugin with Caddy on its [official download page](https://caddyserver.com/download).
## Syntax
```
minify paths... {
if a cond b
if_op [and|or]
disable [js|css|html|json|svg|xml]
minifier option value
}
```+ **paths** are space separated file paths to minify. If nothing is specified, the whole website will be minified.
+ **if** specifies a condition. Multiple ifs are AND-ed together by default. **a** and **b** are any string and may use [request placeholders](https://caddyserver.com/docs/placeholders). **cond** is the condition, with possible values explained in [rewrite](https://caddyserver.com/docs/rewrite#if) (which also has an `if` statement).
+ **if_op** specifies how the ifs are evaluated; the default is `and`.
+ **disable** is used to indicate which minifiers to disable; by default, they're all activated.
+ **minifier** sets **value** for **option** on that minifier. When the option is true or false, its omission is trated as `true`. The possible options are described bellow.### Minifiers options
| Minifier(s) | Option | Value | Description |
| ------------- |------------- | ---------- | ----------- |
| css, svg | decimals | number | Preserves default attribute values. |
| xml, html | keep_whitespace | true\|false | Preserves whitespace between inline tags but still collapse multiple whitespace characters into one. |
| html | keep_end_tags | true\|false | Preserves all end tags. |
| html | keep_document_tags | true\|false | Preserve `html`, `head` and `body` tags. |
| html | keep_default_attr_vals | true\|false | Preserves default value attributes. |
| html | keep_conditional_comments | true\|false | Preserves all IE conditional comments. |For more information about what does each option and how each minifier work, read the [documentation of tdewolff/minify](https://github.com/tdewolff/minify/blob/master/README.md).
## Examples
Minify all of the supported files of the website:
```
minify
```Only minify the contents of `/assets` folder:
```
minify /assets
```Only minify css files:
```
minify {
disable html svg json xml js
}
```Minify the whole website except `/api`:
```
minify {
if {path} not_match ^(\/api).*
}
```Minify the files of `/assets` folder except `/assets/js`:
```
minify /assets {
if {path} not_match ^(\/assets\/js).*
}
```Customize the minifier options:
```
minify {
html keep_document_tags
html keep_whitespace
}
```