1.0.0 • Published 4 years ago

gulp-json2jsvar v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

gulp-js2json

Convert json format to js format

Install

npm install --save-dev gulp-json2jsvar

Usage

Transform example.json:

{
  title:"example"
} 

Into example.js:

var title = 'example';

Using gulpfile.js:

var gulp = require('gulp');
var data = require('gulp-data');
var json2jsrev = require('gulp-json2jsvar');
var res = require('./example/example.json');

gulp.task('json-js', function () {
  return gulp.src('./example/base.js')
    .pipe(data(function(){
      return res;
    }))
    .pipe(json2jsrev({basename:'example'}))
    .pipe(gulp.dest('example'));
});

Credits

Inspired by gulp-file-to-json (Gulp plugin to convert a file and its MD5 hash value into a JSON representation,Obviously, I just copied this project and modified a few lines of code.).

License

MIT © 2016 Vast.com, Inc.