An open API service indexing awesome lists of open source software.

https://github.com/haensl/gulp-embed-json

Gulp plugin to inline/embed JSON data into HTML files.
https://github.com/haensl/gulp-embed-json

automation ci embed gulp gulp-plugin gulp-tasks gulpplugin html inline inline-json json npm npm-module npm-package

Last synced: about 1 month ago
JSON representation

Gulp plugin to inline/embed JSON data into HTML files.

Awesome Lists containing this project

README

          

# gulp-embed-json

Gulp plugin to inline/embed JSON data into HTML files.

[![NPM](https://nodei.co/npm/gulp-embed-json.png?downloads=true)](https://nodei.co/npm/gulp-embed-json/)

[![npm version](https://badge.fury.io/js/gulp-embed-json.svg)](http://badge.fury.io/js/gulp-embed-json)
[![CircleCI](https://circleci.com/gh/haensl/gulp-embed-json.svg?style=svg)](https://circleci.com/gh/haensl/gulp-embed-json)

## Installation

```shell
npm i --save-dev gulp-embed-json
```

## Quick Start
```javascript
const embedJSON = require('gulp-embed-json');

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

This gulp task will inline/embed any scripts with JSON source attribute and respective mime type.

## Options

### mimeTypes `string | Array`

Provide custom mime types to specify which `` tags should be embedded.

#### default: `application/json, application/ld+json`

##### Example: Embed only tags with `type="application/ld+json"`

HTML layout
```html
<html>
<head><!-- ... --></head>
<body>
<!-- ... -->
<script type="application/json" src="data.json">





{"@context":"http://schema.org","@type":"SoftwareApplication","name":"gulp-embed-json"}











{"foo":"bar"}







{
"foo": "bar"
}