# snowpack-plugin-minify-html-literals

> A snowpack plugin to minify HTML template literal strings

Latest version **0.1.1** (published 2022-03-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install snowpack-plugin-minify-html-literals
pnpm add snowpack-plugin-minify-html-literals
yarn add snowpack-plugin-minify-html-literals
bun add snowpack-plugin-minify-html-literals
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-03-25 |
| First published | 2022-03-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=11.14.0 |
| Dependencies | 1 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Akiomi Kamakura |
| Maintainers | akiomik |
| Keywords | snowpack, snowpack-plugin, minify, html, literal, literals, template, tagged, lit-html |

## Links

- npm: https://www.npmjs.com/package/snowpack-plugin-minify-html-literals
- Repository: https://github.com/akiomik/snowpack-plugin-minify-html-literals
- Homepage: https://github.com/akiomik/snowpack-plugin-minify-html-literals#readme
- Issues: https://github.com/akiomik/snowpack-plugin-minify-html-literals/issues
- npm.io page: https://npm.io/package/snowpack-plugin-minify-html-literals

## Dependencies (1)

- [minify-html-literals](https://npm.io/package/minify-html-literals.md) ^1.3.5

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-03-25
- 0.1.0 — 2022-03-22
- 0.0.3 — 2022-03-22
- 0.0.2 — 2022-03-21
- 0.0.1 — 2022-03-19

## README

# snowpack-plugin-minify-html-literals

[![npm version](https://badge.fury.io/js/snowpack-plugin-minify-html-literals.svg)](https://badge.fury.io/js/snowpack-plugin-minify-html-literals)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/6b13cc7a33cb4e6fa0da067964f30f77)](https://www.codacy.com/gh/akiomik/snowpack-plugin-minify-html-literals/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=akiomik/snowpack-plugin-minify-html-literals&amp;utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/6b13cc7a33cb4e6fa0da067964f30f77)](https://www.codacy.com/gh/akiomik/snowpack-plugin-minify-html-literals/dashboard?utm_source=github.com&utm_medium=referral&utm_content=akiomik/snowpack-plugin-minify-html-literals&utm_campaign=Badge_Coverage)
[![Node.js CI](https://github.com/akiomik/snowpack-plugin-minify-html-literals/actions/workflows/node-ci.yml/badge.svg)](https://github.com/akiomik/snowpack-plugin-minify-html-literals/actions/workflows/node-ci.yml)
[![CodeQL](https://github.com/akiomik/snowpack-plugin-minify-html-literals/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/akiomik/snowpack-plugin-minify-html-literals/actions/workflows/codeql-analysis.yml)

`snowpack-plugin-minify-html-literals` is a [snowpack](https://www.snowpack.dev) plugin to minify HTML template literal strings, using [minify-html-literals](https://github.com/asyncLiz/minify-html-literals).

## Installation

```bash
npm install -D snowpack-plugin-minify-html-literals
```

## Usage

### Tagged templates

```js
// snowpack.config.mjs
export default {
  plugins: ['snowpack-plugin-minify-html-literals'],
};
```

```js
// index.js
const html = (strings) => strings.raw[0];
const template = html`
  <div>
    <p>Hello, World!</p>
  </div>
`;

const body = document.querySelector('body');
body.innerHTML = template;
```

```js
// A transformation result of index.js
const html = (strings) => strings.raw[0];
const template = html`<div><p>Hello, World!</p></div>`;

const body = document.querySelector('body');
body.innerHTML = template;
```

### Non-tagged templates

```js
// snowpack.config.mjs
export default {
  plugins: [[
    'snowpack-plugin-minify-html-literals',
    {
      options: {
        shouldMinify: (template) => {
          return template.parts.some(part => part.text.includes('data-minify="true"'));
        },
      },
    },
  ]],
};
```

```js
// index.js
const template = `
  <div data-minify="true">
    <p>Hello, World!</p>
  </div>
`;

const body = document.querySelector('body');
body.innerHTML = template;
```

```js
// A transformation result of index.js
const template = `<div data-minify="true"><p>Hello, World!</p></div>`;

const body = document.querySelector('body');
body.innerHTML = template;
```

## Options

```js
// snowpack.config.mjs
export default {
  plugins: [[
    'snowpack-plugin-minify-html-literals',
    {
      options: null, // minify-html-literals options. See https://github.com/asyncLiz/minify-html-literals#options
      exts: ['.js', '.mjs', '.ts'], // target file extensions
    }
  ]],
};
```

---
_Source: https://npm.io/package/snowpack-plugin-minify-html-literals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
