htmlnano 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -12
- package/dist/_modules/collapseAttributeWhitespace.d.mts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.d.ts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.js +296 -0
- package/dist/_modules/collapseAttributeWhitespace.mjs +293 -0
- package/dist/_modules/collapseBooleanAttributes.d.mts +60 -0
- package/dist/_modules/collapseBooleanAttributes.d.ts +60 -0
- package/dist/_modules/collapseBooleanAttributes.js +159 -0
- package/{lib/modules → dist/_modules}/collapseBooleanAttributes.mjs +39 -57
- package/dist/_modules/collapseWhitespace.d.mts +57 -0
- package/dist/_modules/collapseWhitespace.d.ts +57 -0
- package/dist/_modules/collapseWhitespace.js +172 -0
- package/dist/_modules/collapseWhitespace.mjs +170 -0
- package/dist/_modules/custom.d.mts +57 -0
- package/dist/_modules/custom.d.ts +57 -0
- package/dist/_modules/custom.js +22 -0
- package/dist/_modules/custom.mjs +20 -0
- package/dist/_modules/deduplicateAttributeValues.d.mts +56 -0
- package/dist/_modules/deduplicateAttributeValues.d.ts +56 -0
- package/dist/_modules/deduplicateAttributeValues.js +38 -0
- package/dist/_modules/deduplicateAttributeValues.mjs +36 -0
- package/dist/_modules/example.d.mts +59 -0
- package/dist/_modules/example.d.ts +59 -0
- package/dist/_modules/example.js +67 -0
- package/dist/_modules/example.mjs +65 -0
- package/dist/_modules/mergeScripts.d.mts +56 -0
- package/dist/_modules/mergeScripts.d.ts +56 -0
- package/dist/_modules/mergeScripts.js +53 -0
- package/dist/_modules/mergeScripts.mjs +51 -0
- package/dist/_modules/mergeStyles.d.mts +56 -0
- package/dist/_modules/mergeStyles.d.ts +56 -0
- package/dist/_modules/mergeStyles.js +42 -0
- package/dist/_modules/mergeStyles.mjs +40 -0
- package/dist/_modules/minifyConditionalComments.d.mts +56 -0
- package/dist/_modules/minifyConditionalComments.d.ts +56 -0
- package/dist/_modules/minifyConditionalComments.js +54 -0
- package/{lib/modules → dist/_modules}/minifyConditionalComments.mjs +21 -22
- package/dist/_modules/minifyCss.d.mts +56 -0
- package/dist/_modules/minifyCss.d.ts +56 -0
- package/dist/_modules/minifyCss.js +84 -0
- package/dist/_modules/minifyCss.mjs +82 -0
- package/dist/_modules/minifyJs.d.mts +56 -0
- package/dist/_modules/minifyJs.d.ts +56 -0
- package/dist/_modules/minifyJs.js +108 -0
- package/dist/_modules/minifyJs.mjs +106 -0
- package/dist/_modules/minifyJson.d.mts +56 -0
- package/dist/_modules/minifyJson.d.ts +56 -0
- package/dist/_modules/minifyJson.js +35 -0
- package/dist/_modules/minifyJson.mjs +33 -0
- package/dist/_modules/minifySvg.d.mts +56 -0
- package/dist/_modules/minifySvg.d.ts +56 -0
- package/dist/_modules/minifySvg.js +40 -0
- package/dist/_modules/minifySvg.mjs +38 -0
- package/dist/_modules/minifyUrls.d.mts +56 -0
- package/dist/_modules/minifyUrls.d.ts +56 -0
- package/dist/_modules/minifyUrls.js +180 -0
- package/dist/_modules/minifyUrls.mjs +178 -0
- package/dist/_modules/normalizeAttributeValues.d.mts +56 -0
- package/dist/_modules/normalizeAttributeValues.d.ts +56 -0
- package/dist/_modules/normalizeAttributeValues.js +234 -0
- package/dist/_modules/normalizeAttributeValues.mjs +232 -0
- package/dist/_modules/removeAttributeQuotes.d.mts +56 -0
- package/dist/_modules/removeAttributeQuotes.d.ts +56 -0
- package/dist/_modules/removeAttributeQuotes.js +15 -0
- package/dist/_modules/removeAttributeQuotes.mjs +13 -0
- package/dist/_modules/removeComments.d.mts +58 -0
- package/dist/_modules/removeComments.d.ts +58 -0
- package/dist/_modules/removeComments.js +83 -0
- package/{lib/modules → dist/_modules}/removeComments.mjs +24 -35
- package/dist/_modules/removeEmptyAttributes.d.mts +56 -0
- package/dist/_modules/removeEmptyAttributes.d.ts +56 -0
- package/dist/_modules/removeEmptyAttributes.js +197 -0
- package/dist/_modules/removeEmptyAttributes.mjs +195 -0
- package/dist/_modules/removeOptionalTags.d.mts +56 -0
- package/dist/_modules/removeOptionalTags.d.ts +56 -0
- package/dist/_modules/removeOptionalTags.js +190 -0
- package/{lib/modules → dist/_modules}/removeOptionalTags.mjs +54 -91
- package/dist/_modules/removeRedundantAttributes.d.mts +57 -0
- package/dist/_modules/removeRedundantAttributes.d.ts +57 -0
- package/dist/_modules/removeRedundantAttributes.js +128 -0
- package/{lib/modules → dist/_modules}/removeRedundantAttributes.mjs +43 -59
- package/dist/_modules/removeUnusedCss.d.mts +60 -0
- package/dist/_modules/removeUnusedCss.d.ts +60 -0
- package/dist/_modules/removeUnusedCss.js +134 -0
- package/dist/_modules/removeUnusedCss.mjs +132 -0
- package/dist/_modules/sortAttributes.d.mts +57 -0
- package/dist/_modules/sortAttributes.d.ts +57 -0
- package/dist/_modules/sortAttributes.js +102 -0
- package/{lib/modules → dist/_modules}/sortAttributes.mjs +39 -58
- package/dist/_modules/sortAttributesWithLists.d.mts +56 -0
- package/dist/_modules/sortAttributesWithLists.d.ts +56 -0
- package/dist/_modules/sortAttributesWithLists.js +118 -0
- package/{lib/modules → dist/_modules}/sortAttributesWithLists.mjs +41 -59
- package/dist/helpers.js +72 -0
- package/dist/helpers.mjs +63 -0
- package/dist/index.js +223 -0
- package/dist/index.mjs +209 -0
- package/dist/presets/ampSafe.js +19 -0
- package/{lib → dist}/presets/ampSafe.mjs +6 -4
- package/dist/presets/max.js +28 -0
- package/{lib → dist}/presets/max.mjs +6 -4
- package/dist/presets/safe.js +60 -0
- package/{lib → dist}/presets/safe.mjs +13 -20
- package/package.json +48 -56
- package/.eslintignore +0 -3
- package/CHANGELOG.md +0 -409
- package/docs/README.md +0 -33
- package/docs/babel.config.js +0 -3
- package/docs/docs/010-introduction.md +0 -22
- package/docs/docs/020-usage.md +0 -117
- package/docs/docs/030-config.md +0 -21
- package/docs/docs/040-presets.md +0 -75
- package/docs/docs/050-modules.md +0 -855
- package/docs/docs/060-contribute.md +0 -16
- package/docs/docusaurus.config.js +0 -65
- package/docs/netlify.toml +0 -4
- package/docs/package-lock.json +0 -21630
- package/docs/package.json +0 -40
- package/docs/sidebars.js +0 -26
- package/docs/versioned_docs/version-1.1.1/010-introduction.md +0 -22
- package/docs/versioned_docs/version-1.1.1/020-usage.md +0 -77
- package/docs/versioned_docs/version-1.1.1/030-config.md +0 -21
- package/docs/versioned_docs/version-1.1.1/040-presets.md +0 -75
- package/docs/versioned_docs/version-1.1.1/050-modules.md +0 -785
- package/docs/versioned_docs/version-1.1.1/060-contribute.md +0 -16
- package/docs/versioned_docs/version-2.0.0/010-introduction.md +0 -22
- package/docs/versioned_docs/version-2.0.0/020-usage.md +0 -77
- package/docs/versioned_docs/version-2.0.0/030-config.md +0 -21
- package/docs/versioned_docs/version-2.0.0/040-presets.md +0 -75
- package/docs/versioned_docs/version-2.0.0/050-modules.md +0 -838
- package/docs/versioned_docs/version-2.0.0/060-contribute.md +0 -16
- package/docs/versioned_sidebars/version-1.1.1-sidebars.json +0 -8
- package/docs/versioned_sidebars/version-2.0.0-sidebars.json +0 -8
- package/docs/versions.json +0 -4
- package/index.cjs +0 -11
- package/index.d.cts +0 -3
- package/index.d.mts +0 -3
- package/index.d.ts +0 -94
- package/index.mjs +0 -2
- package/lib/helpers.cjs +0 -79
- package/lib/helpers.mjs +0 -53
- package/lib/htmlnano.cjs +0 -202
- package/lib/htmlnano.mjs +0 -198
- package/lib/modules/collapseAttributeWhitespace.cjs +0 -86
- package/lib/modules/collapseAttributeWhitespace.mjs +0 -104
- package/lib/modules/collapseBooleanAttributes.cjs +0 -62
- package/lib/modules/collapseWhitespace.cjs +0 -100
- package/lib/modules/collapseWhitespace.mjs +0 -132
- package/lib/modules/custom.cjs +0 -19
- package/lib/modules/custom.mjs +0 -16
- package/lib/modules/deduplicateAttributeValues.cjs +0 -38
- package/lib/modules/deduplicateAttributeValues.mjs +0 -40
- package/lib/modules/example.cjs +0 -85
- package/lib/modules/example.mjs +0 -75
- package/lib/modules/mergeScripts.cjs +0 -54
- package/lib/modules/mergeScripts.mjs +0 -56
- package/lib/modules/mergeStyles.cjs +0 -38
- package/lib/modules/mergeStyles.mjs +0 -36
- package/lib/modules/minifyConditionalComments.cjs +0 -47
- package/lib/modules/minifyCss.cjs +0 -73
- package/lib/modules/minifyCss.mjs +0 -88
- package/lib/modules/minifyJs.cjs +0 -103
- package/lib/modules/minifyJs.mjs +0 -121
- package/lib/modules/minifyJson.cjs +0 -24
- package/lib/modules/minifyJson.mjs +0 -21
- package/lib/modules/minifySvg.cjs +0 -37
- package/lib/modules/minifySvg.mjs +0 -30
- package/lib/modules/minifyUrls.cjs +0 -141
- package/lib/modules/minifyUrls.mjs +0 -229
- package/lib/modules/normalizeAttributeValues.cjs +0 -120
- package/lib/modules/normalizeAttributeValues.mjs +0 -140
- package/lib/modules/removeAttributeQuotes.cjs +0 -17
- package/lib/modules/removeAttributeQuotes.mjs +0 -12
- package/lib/modules/removeComments.cjs +0 -86
- package/lib/modules/removeEmptyAttributes.cjs +0 -72
- package/lib/modules/removeEmptyAttributes.mjs +0 -121
- package/lib/modules/removeOptionalTags.cjs +0 -183
- package/lib/modules/removeRedundantAttributes.cjs +0 -112
- package/lib/modules/removeUnusedCss.cjs +0 -113
- package/lib/modules/removeUnusedCss.mjs +0 -122
- package/lib/modules/sortAttributes.cjs +0 -98
- package/lib/modules/sortAttributesWithLists.cjs +0 -114
- package/lib/presets/ampSafe.cjs +0 -18
- package/lib/presets/max.cjs +0 -27
- package/lib/presets/safe.cjs +0 -65
- package/test.js +0 -23
package/docs/README.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Website
|
|
2
|
-
|
|
3
|
-
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```console
|
|
8
|
-
yarn install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Local Development
|
|
12
|
-
|
|
13
|
-
```console
|
|
14
|
-
yarn start
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
|
|
18
|
-
|
|
19
|
-
## Build
|
|
20
|
-
|
|
21
|
-
```console
|
|
22
|
-
yarn build
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
|
26
|
-
|
|
27
|
-
## Deployment
|
|
28
|
-
|
|
29
|
-
```console
|
|
30
|
-
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|
package/docs/babel.config.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 1
|
|
3
|
-
slug: /
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Introduction
|
|
7
|
-
|
|
8
|
-
Modular HTML minifier, built on top of the [PostHTML](https://github.com/posthtml/posthtml).
|
|
9
|
-
Inspired by [cssnano](http://cssnano.co/).
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## [Benchmark](https://github.com/maltsev/html-minifiers-benchmark/blob/master/README.md)
|
|
13
|
-
[html-minifier-terser@5.1.1]: https://www.npmjs.com/package/html-minifier-terser
|
|
14
|
-
[htmlnano@2.0.0]: https://www.npmjs.com/package/htmlnano
|
|
15
|
-
|
|
16
|
-
| Website | Source (KB) | [html-minifier-terser@5.1.1] | [htmlnano@2.0.0] |
|
|
17
|
-
|---------|------------:|----------------:|-----------:|
|
|
18
|
-
| [stackoverflow.blog](https://stackoverflow.blog/) | 95 | 87 | 82 |
|
|
19
|
-
| [github.com](https://github.com/) | 210 | 183 | 171 |
|
|
20
|
-
| [en.wikipedia.org](https://en.wikipedia.org/wiki/Main_Page) | 78 | 72 | 72 |
|
|
21
|
-
| [npmjs.com](https://www.npmjs.com/features) | 41 | 38 | 36 |
|
|
22
|
-
| **Avg. minify rate** | 0% | **9%** | **13%** |
|
package/docs/docs/020-usage.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# Usage
|
|
2
|
-
## Javascript
|
|
3
|
-
```js
|
|
4
|
-
const htmlnano = require('htmlnano');
|
|
5
|
-
const options = {
|
|
6
|
-
removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
|
|
7
|
-
collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
|
8
|
-
};
|
|
9
|
-
// posthtml, posthtml-render, and posthtml-parse options
|
|
10
|
-
const postHtmlOptions = {
|
|
11
|
-
sync: true, // https://github.com/posthtml/posthtml#usage
|
|
12
|
-
lowerCaseTags: true, // https://github.com/posthtml/posthtml-parser#options
|
|
13
|
-
quoteAllAttributes: false, // https://github.com/posthtml/posthtml-render#options
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
htmlnano
|
|
17
|
-
// "preset" arg might be skipped (see "Presets" section below for more info)
|
|
18
|
-
// "postHtmlOptions" arg might be skipped
|
|
19
|
-
.process(html, options, preset, postHtmlOptions)
|
|
20
|
-
.then(function (result) {
|
|
21
|
-
// result.html is minified
|
|
22
|
-
})
|
|
23
|
-
.catch(function (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
});
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## PostHTML
|
|
30
|
-
Just add `htmlnano` as a final plugin:
|
|
31
|
-
```js
|
|
32
|
-
const posthtml = require('posthtml');
|
|
33
|
-
const options = {
|
|
34
|
-
removeComments: false, // Disable the module "removeComments"
|
|
35
|
-
collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
|
36
|
-
};
|
|
37
|
-
const posthtmlPlugins = [
|
|
38
|
-
/* other PostHTML plugins */
|
|
39
|
-
|
|
40
|
-
require('htmlnano')(options)
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
const posthtmlOptions = {
|
|
44
|
-
// See PostHTML docs
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
posthtml(posthtmlPlugins)
|
|
48
|
-
.process(html, posthtmlOptions)
|
|
49
|
-
.then(function (result) {
|
|
50
|
-
// result.html is minified
|
|
51
|
-
})
|
|
52
|
-
.catch(function (err) {
|
|
53
|
-
console.error(err);
|
|
54
|
-
});
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Webpack
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
npm install html-minimizer-webpack-plugin --save-dev
|
|
62
|
-
npm install htmlnano --save-dev
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
```js
|
|
66
|
-
// webpack.config.js
|
|
67
|
-
const HtmlMinimizerWebpackPlugin = require('html-minimizer-webpack-plugin');
|
|
68
|
-
const htmlnano = require('htmlnano');
|
|
69
|
-
|
|
70
|
-
module.exports = {
|
|
71
|
-
optimization: {
|
|
72
|
-
minimize: true,
|
|
73
|
-
minimizer: [
|
|
74
|
-
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
|
|
75
|
-
// `...`,
|
|
76
|
-
new HtmlMinimizerWebpackPlugin({
|
|
77
|
-
// Add HtmlMinimizerWebpackPlugin's option here, see https://webpack.js.org/plugins/html-minimizer-webpack-plugin/#options
|
|
78
|
-
// test: /\.html(\?.*)?$/i,
|
|
79
|
-
|
|
80
|
-
// Use htmlnano as HtmlMinimizerWebpackPlugin's minimizer
|
|
81
|
-
minify: htmlnano.htmlMinimizerWebpackPluginMinify,
|
|
82
|
-
minimizerOptions: {
|
|
83
|
-
// Add htmlnano's option here
|
|
84
|
-
removeComments: false, // Disable the module "removeComments"
|
|
85
|
-
collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## Gulp
|
|
96
|
-
```bash
|
|
97
|
-
npm i -D gulp-posthtml htmlnano
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
const gulp = require('gulp');
|
|
102
|
-
const posthtml = require('gulp-posthtml');
|
|
103
|
-
const htmlnano = require('htmlnano');
|
|
104
|
-
const options = {
|
|
105
|
-
removeComments: false
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
gulp.task('default', function() {
|
|
109
|
-
return gulp
|
|
110
|
-
.src('./index.html')
|
|
111
|
-
.pipe(posthtml([
|
|
112
|
-
// Add `htmlnano` as a final plugin
|
|
113
|
-
htmlnano(options)
|
|
114
|
-
]))
|
|
115
|
-
.pipe(gulp.dest('./build'));
|
|
116
|
-
});
|
|
117
|
-
```
|
package/docs/docs/030-config.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Config
|
|
2
|
-
|
|
3
|
-
There are two main ways to configure htmlnano:
|
|
4
|
-
|
|
5
|
-
## Passing options to `htmlnano` directly
|
|
6
|
-
This is the way described above in the examples.
|
|
7
|
-
|
|
8
|
-
## Using configuration file
|
|
9
|
-
Alternatively, you might create a configuration file (e.g., `htmlnanorc.json` or `htmlnanorc.js`) or save options to `package.json` with `htmlnano` key.
|
|
10
|
-
`htmlnano` uses `cosmiconfig`, so refer to [its documentation](https://github.com/davidtheclark/cosmiconfig/blob/main/README.md) for a more detailed description.
|
|
11
|
-
|
|
12
|
-
If you want to specify a preset that way, use `preset` key:
|
|
13
|
-
|
|
14
|
-
```json
|
|
15
|
-
{
|
|
16
|
-
"preset": "max",
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Configuration files have lower precedence than passing options to `htmlnano` directly.
|
|
21
|
-
So if you use both ways, then the configuration file would be ignored.
|
package/docs/docs/040-presets.md
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# Presets
|
|
2
|
-
|
|
3
|
-
A preset is just an object with modules config.
|
|
4
|
-
|
|
5
|
-
Currently the following presets are available:
|
|
6
|
-
- [safe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) — a default preset for minifying a regular HTML in a safe way (without breaking anything)
|
|
7
|
-
- [ampSafe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/ampSafe.mjs) - same as `safe` preset but for [AMP pages](https://www.ampproject.org/)
|
|
8
|
-
- [max](https://github.com/posthtml/htmlnano/blob/master/lib/presets/max.mjs) - maximal minification (might break some pages)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
You can use them the following way:
|
|
12
|
-
```js
|
|
13
|
-
const htmlnano = require('htmlnano');
|
|
14
|
-
const ampSafePreset = require('htmlnano').presets.ampSafe;
|
|
15
|
-
const options = {
|
|
16
|
-
// Your options
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
htmlnano
|
|
20
|
-
.process(html, options, ampSafePreset)
|
|
21
|
-
.then(function (result) {
|
|
22
|
-
// result.html is minified
|
|
23
|
-
})
|
|
24
|
-
.catch(function (err) {
|
|
25
|
-
console.error(err);
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
If you skip `preset` argument [`safe`](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) preset would be used by default.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
If you'd like to define your very own config without any presets pass an empty object as a preset:
|
|
33
|
-
```js
|
|
34
|
-
const htmlnano = require('htmlnano');
|
|
35
|
-
const options = {
|
|
36
|
-
// Your options
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
htmlnano
|
|
40
|
-
.process(html, options, {})
|
|
41
|
-
.then(function (result) {
|
|
42
|
-
// result.html is minified
|
|
43
|
-
})
|
|
44
|
-
.catch(function (err) {
|
|
45
|
-
console.error(err);
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
You might create also your own presets:
|
|
51
|
-
```js
|
|
52
|
-
const htmlnano = require('htmlnano');
|
|
53
|
-
// Preset for minifying email templates
|
|
54
|
-
const emailPreset = {
|
|
55
|
-
mergeStyles: true,
|
|
56
|
-
minifyCss: {
|
|
57
|
-
safe: true
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const options = {
|
|
62
|
-
// Some specific options
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
htmlnano
|
|
66
|
-
.process(html, options, emailPreset)
|
|
67
|
-
.then(function (result) {
|
|
68
|
-
// result.html is minified
|
|
69
|
-
})
|
|
70
|
-
.catch(function (err) {
|
|
71
|
-
console.error(err);
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Feel free [to submit a PR](https://github.com/posthtml/htmlnano/issues/new) with your preset if it might be useful for other developers as well.
|