1.4.12 • Published 8 months ago

gulp-minify-inline-json v1.4.12

Weekly downloads
56
License
MIT
Repository
github
Last release
8 months ago

gulp-minify-inline-json

NPM

npm version CircleCI

Minifies inline <script> tags containing JSON data, i.e. application/json and application/ld+json.

Installation

npm i --save-dev gulp-minify-inline-json

Usage

const minifyInlineJSON = require('gulp-minify-inline-json');

gulp.task('minifyInlineJSON', () =>
  gulp.src('*.html')
    .pipe(minifyInlineJSON())
    .pipe(gulp.dest('dist/')));

Options

mimeTypes Array<string>

Provide custom mime types to specify which <script> tags to minify.

default: [ 'application/json', 'application/ld+json' ]
Example: Minify only tags with type="application/ld+json"
HTML Layout
<html>
  <head><!-- ... --></head>
  <body>
    <!-- ... -->
    <script type="application/json">{
      "some": "json"
    }</script>
    <script type="application/ld+json">{
      "foo": "bar"
    }</script>
  </body>
</html>
Gulp task
  const minifyJSON = require('gulp-minify-inline-json');

  gulp.task('minifyJSON', () =>
    gulp.src('*.html')
      .pipe(minifyJSON({
        mimeTypes: [
          'application/ld+json'
        ]
      }))
      .pipe(gulp.dest('dist/')));
Output
<html>
  <head><!-- ... --></head>
  <body>
    <!-- ... -->
    <script type="application/json">{
      "some": "json"
    }</script>
    <script type="application/ld+json">{"foo":"bar"}</script>
  </body>
</html>

Changelog

License

1.4.12

8 months ago

1.4.11

1 year ago

1.4.10

2 years ago

1.4.9

2 years ago

1.4.6

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.4.5

2 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.4

4 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago