Daan Poron
Daan Poron

Reputation: 2758

extend yeoman build process to minify json

i'm looking for a way to extend the build process of yeoman with something to minify json files ... i found a npm package which can minify json files but it doesn't export any functions :/ anyone that knows how to integrate this into the yeoman build process?

https://npmjs.org/package/json-minify

kind regards,

Daan

Upvotes: 1

Views: 389

Answers (1)

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

Here is a one liner to minify JSON in node.js: JSON.stringify(JSON.parse(jsonStr));

I threw together a grunt-minjson plugin. Install with npm install grunt-minjson --save-dev, add grunt.loadNpmTasks('grunt-minjson'); to your Gruntfile and configure like such:

grunt.initConfig({
  minjson: {
    compile: {
      files: {
        'all.min.json': ['jsonfiles/*.json']
      }
    }
  }
});

Here is a link to the project: https://github.com/shama/grunt-minjson

Upvotes: 4

Related Questions