Skip to content

A JSON minification plugin / asset compiler for the Play! Framework

License

Notifications You must be signed in to change notification settings

joscha/play-jsonminify

Repository files navigation

play-jsonminify - JSON minification compiler for Play 2.0

About

This plugin is initially based on Ray and play-stylus.

play-jsonminify is a JSON 'compiled asset plugin' for Play 2.0 based on JSON.simple. It is similar to the other built-in compilers. JSON files placed under app/assets will be transformed into a pretty-printed and a compressed version.

For example, JSON in app/assets/javascripts/xyz.json

will be automatically compiled into a pretty-printed version, when requested via public/javascripts/xyz.json:

and a compressed version when requested via public/javascripts/xyz.min.json:

Compile time errors (such as unclosed brackets or unexpected characters) will cause a nice Play error page:

As you can see on line 3, leaving out commas is not necessarily breaking the compiler. As well as unnecessary trailing commas will be stripped automatically. (thanks to JSON.simple).

Installation

Add the plugin and the repository to your application's project/plugins.sbt:

resolvers += "Play JSONminify repository" at "http://joscha.github.com/play-jsonminify/repo/"

addSbtPlugin("com.feth" % "play-jsonminify" % "0.1.0")

This adds the JSON asset compiler to your Play project. *.json files beneath app/assets will then be automatically compiled to *.json and *.min.json files. Files starting with _-character will be left out from compilation as per Play convention.

Installation (build from source)

First you must publish the plugin to your Play 2.0 repository. You will have to specify your top level play directory and the version:

sbt -Dplay.path=../play-2.0.1 -Dplay.version=2.0.1 publish

Then add the plugin to your application's project/plugins.sbt:

addSbtPlugin("com.feth" % "play-jsonminify" % "0.1.0")

Settings

To override the default settings, you can add the following lines to the settings call in your Build.scala (examples):

this would for example also process JSON files starting with the _-character:

jsonminifyEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.json")

Versions

  • 0.1.0 [2012-05-18] Initial release

License

Copyright (c) 2012 Joscha Feth

MIT-style license, see details from LICENSE file.

About

A JSON minification plugin / asset compiler for the Play! Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published