Skip to content

Commit

Permalink
feat: minify CSS tagged template literals
Browse files Browse the repository at this point in the history
  • Loading branch information
asyncLiz committed Feb 13, 2019
1 parent 2867985 commit 6baf3c2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
36 changes: 35 additions & 1 deletion README.md
Expand Up @@ -4,7 +4,7 @@
[![Build Status](https://travis-ci.com/asyncLiz/rollup-plugin-minify-html-literals.svg?branch=master)](https://travis-ci.com/asyncLiz/rollup-plugin-minify-html-literals)
[![Coverage Status](https://coveralls.io/repos/github/asyncLiz/rollup-plugin-minify-html-literals/badge.svg?branch=master)](https://coveralls.io/github/asyncLiz/rollup-plugin-minify-html-literals?branch=master)

Uses [minify-html-literals](https://www.npmjs.com/package/minify-html-literals) to minify HTML markup inside JavaScript template literal strings.
Uses [minify-html-literals](https://www.npmjs.com/package/minify-html-literals) to minify HTML and CSS markup inside JavaScript template literal strings.

## Usage

Expand All @@ -25,6 +25,8 @@ export default {
};
```

By default, this will minify any tagged template literal string whose tag contains "html" or "css" (case insensitive). [Additional options](https://www.npmjs.com/package/minify-html-literals#options) may be specified to control what templates should be minified.

## Options

```js
Expand Down Expand Up @@ -52,3 +54,35 @@ export default {
]
};
```

## Examples

### Minify Polymer Templates

```js
import minifyHTML from 'rollup-plugin-minify-html-literals';
import { defaultShouldMinify } from 'minify-html-literals';

export default {
entry: 'index.js',
dest: 'dist/index.js',
plugins: [
minifyHTML({
options: {
shouldMinify(template) {
return (
defaultShouldMinify(template) ||
template.parts.some(part => {
// Matches Polymer templates that are not tagged
return (
part.text.includes('<style') ||
part.text.includes('<dom-module')
);
})
);
}
}
})
]
};
```
31 changes: 17 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -56,11 +56,11 @@
"all": true
},
"dependencies": {
"minify-html-literals": "^1.1.2",
"minify-html-literals": "^1.2.0",
"rollup-pluginutils": "^2.3.0"
},
"peerDependencies": {
"rollup": "^0.65.2||^1"
"rollup": "^0.65.2 || ^1.0.0"
},
"devDependencies": {
"@types/chai": "^4.1.4",
Expand Down

0 comments on commit 6baf3c2

Please sign in to comment.