1.1.22 • Published 3 years ago

gulp-minify-html-literals v1.1.22

Weekly downloads
12
License
MIT
Repository
gitlab
Last release
3 years ago

Gulp plugin for minifying HTML literals

npm Maintenance npm npm NodeJS npm

This plugin is a Gulp wrapper for minify-html-literals.

Minify HTML in your ES2015 (or later) string literals, e.g. when using polymer or lit-element or custom webcomponents or other JavaScript files that uses ECMASCRIPT string literals with HTML.

Getting started

npm i gulp-minify-html-literals

Example usage

Considering this source in ./my-widgets/BttgTestWidget.js:

class BttgTestWidget extends $.classes.Widget {

  constructor() {

    super();

    this.test = 'test';

  }

  template() {
    return html`
      <h1>Test 1</h1>
      <p>This is a ${this.test}.</p>
      <p>This HTML should be minified.</p>
      `;
  }

  render() {
    return this.template();
  }

  static get is() {
    return 'bttg-test-widget';
  }

}

$.classes.Widget.def(BttgTestWidget.is, BttgTestWidget);

you can minify both javascript and the template html when with this gulpfile.js:

const {
  src,
  dest,
  parallel,
  series
} = require('gulp');

const gulpMinifyJsTemplate = require('gulp-minify-html-literals');

const distWidgets = () =>
  src([`./my-widgets/**/*.js`])
  .pipe(minifyJSTemplate()) //or with options minifyJSTemplate({...})
  .pipe(dest('./dist/js/widgets/'));

module.exports = {

  default: distWidgets

};

For the actual options, see minify-html-literals.

License

Gulp Minify HTML Literals is MIT licensed.

static Twitter Follow static Twitter Follow

1.1.22

3 years ago

1.1.21

3 years ago

1.1.20

3 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.10

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.0

4 years ago