Giter Site home page Giter Site logo

grunt-minjson's Introduction

grunt-minjson

A Grunt plugin to minify and concat JSON files.

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide.

From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:

npm install grunt-minjson --save-dev

Once that's done, add this line to your project's Gruntfile:

grunt.loadNpmTasks('grunt-minjson');

If the plugin has been installed correctly, running grunt --help at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a devDependency, which ensures that it will be installed whenever the npm install command is run.

The "minjson" task

Usage Examples

grunt.initConfig({
  minjson: {
    compile: {
      files: {
        // Minify one json file
        'one.min.json': 'one.json',
        // Concat/minify one.json and all json files within the data folder
        // If more than one json file is matched, json will be wrapped in brackets []
        'all.min.json': ['one.json', 'data/*.json']
      }
    }
  }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

  • 0.4.0 grunt.fail.warn on errors (@guyzmuch).
  • 0.3.0 Replacing json5 with plain JSON.stringify (@brunomperes).
  • 0.2.0 Updating json5 to 0.4.0. Print size comparison (@brunomperes).
  • 0.1.1 Support for Grunt v0.4.
  • 0.1.0 Initial release.

grunt-minjson's People

Contributors

shama avatar brunomperes avatar

Stargazers

Cat  avatar Kenneth John avatar prasanna pulukurthi avatar John Spiteri avatar  avatar Rihards Paskausks avatar Frank avatar Edward Hotchkiss avatar Chris Tabor avatar  avatar John Goodall avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

grunt-minjson's Issues

support regex

Maybe something like this?

     minjson:        
        files: [
          expand: yes
          cwd: '<%= yeoman.app %>/static'
          src: ['**']
          dest: '<%= yeoman.dist %>/static'
        ]

Empty JSON File

EDIT : this happens when paths are badly written (was my case. Sorry)/ However, no error is shown in the log during grunt task. Merge this with other Issue.

When running the task, all JSON minyfied JSON files are empty.
Tested with this JSON file contents :
{
"one": "Singular sensation",
"two": "Beady little eyes",
"three": "Little birds pitch by my doorstep"
}

UTF-16 Files

I'm trying to use this for language files, some of which are UTF-16, but it seems to not keep the same encoding and I guess it's read/writing into different encoding formats.

Is it possible to keep it consistent or specify it in the config somewhere?

JSON5 vs JSON

Hi @shama ,
After pushing #7, the outputted JSON seemed to be with the keys on the first depth without quotes on my input (no idea why), which was making my Angular application crash because it uses the standard JSON.stringify() instead of JSON5.

So I was wondering why using the JSON5, as it could generate JSONs that aren't supported on other applications. Perhaps parameterizing the usage of JSON5 in favor of the standard version of JSON or JSON3?

Grunt 0.4 Release

I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.

If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.

If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8" as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0" to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.

Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.

Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!

If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.

Thanks, we really appreciate your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.