1.0.0 • Published 7 years ago
gulp-html-transform-minify-inline-json v1.0.0
gulp-html-transform-minify-inline-json
This is a plugin for gulp-html-transform
Minifies inline <script>
tags containing JSON data, i.e. application/json
and application/ld+json
.
Loosely based on gulp-minify-inline-json
Installing
Using npm
$ npm install --save gulp-html-transform-inline-json
Using yarn
$ yarn add gulp-html-transform-inline-json
Usage
gulpfile.js
const path = require('path')
const { transform } = require('gulp-html-transform')
const { minifyInlineJson } = require('gulp-html-transform-minify-inline-json')
gulp.task('html', () => {
gulp.src('src/**/*.html')
.pipe(transform(
minifyInlineJson({
mimetypes: ['application/json'], // optional
})
))
.pipe(gulp.dest('dist'))
})
If you want to add the styles manually you can import index.css
from the package folder and remove addStyles
.
Html in:
<script type="application/json">
{
"key": {
"other_key": "value"
}
}
</script>
Html out:
<script type="application/json">{"key":{"other_key":"value"}}</script>
API
minifyInlineJson({
mimetypes: ['application/json', 'application/ld+json'], // optional string array of mimeTypes.
})
1.0.0
7 years ago