JAWR css/Javascript combine and compress module

166 views
Skip to first unread message

John Pletka

unread,
Aug 4, 2010, 2:19:07 PM8/4/10
to play-fr...@googlegroups.com
I'm looking for a module similar to http://grails.org/plugin/jawr that will automatically combine,compress and version a group of javascript and css files.  I've looked at the Press module (http://www.playframework.org/modules/press) and GreenScript (http://www.playframework.org/modules/greenscript), but they only do the compression.  Does anything like that exist out in Play land?


dirk

unread,
Aug 4, 2010, 2:41:33 PM8/4/10
to play-fr...@googlegroups.com
press (and I think greenscript) will compress and combine.
Could you be more specific about what functionality is missing? Maybe I can add it to the press module.

On Wed, Aug 4, 2010 at 3:19 PM, John Pletka <jpl...@abraxis.com> wrote:
I'm looking for a module similar to http://grails.org/plugin/jawr that will automatically combine,compress and version a group of javascript and css files.  I've looked at the Press module (http://www.playframework.org/modules/press) and GreenScript (http://www.playframework.org/modules/greenscript), but they only do the compression.  Does anything like that exist out in Play land?


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

John Pletka

unread,
Aug 4, 2010, 3:41:13 PM8/4/10
to play-fr...@googlegroups.com
That great!  From the description on the modules page, I thought it was only using the YUI compressor.  It does not appear to work properly with the latest 1.1 nightly build though.  It creates the "press" directory but fails to write the file into it.

dirk

unread,
Aug 4, 2010, 10:57:08 PM8/4/10
to play-fr...@googlegroups.com
press will aggregate and compress into a single archive any javascript files that have been added with the {press.script} tag. You also need to output a {press.compressed-script} tag to indicate where to output a reference to the archived file.
By default compression is disabled in dev mode, and enabled in production mode.

There's more information in the documentation:
http://www.playframework.org/modules/press-1.0.1/home

Have you replaced all <script> tags with {press.script} tags, and included a {press.compressed-script} tag? If so, check that you have a line like the following in application.conf:
press.enabled=true

If you're still having problems please send me some example code so I can try to work out what might be the problem
Dirk

John Pletka

unread,
Aug 5, 2010, 9:10:30 AM8/5/10
to play-fr...@googlegroups.com
I've tried Press with both play-1.1-unstable-r982 and play-1.0.3.2 and got the same behavior (compressed file not written)

In my main.html template, I have:
#{press.stylesheet 'main.css' /}
#{press.stylesheet 'reports.css' /}
#{press.compressed-stylesheet /}

In my application.conf
module.press=${play.path}/modules/press-1.0.1
press.enabled=true

My css is in:
/public/stylesheets

Press creates a directory /public/stylesheets/press automatically, but the combined file is not written into it. 
Windows XP
Java 1.5.0_12-b04

dirk

unread,
Aug 5, 2010, 9:14:25 AM8/5/10
to play-fr...@googlegroups.com
Could you also give an example of the html it generates as well? Not the whole document, just the part where it outputs the javascript files. Also, please check the output window/logs for errors (if you are running play with "play run" it will show exceptions in the console, otherwise in logs/system.out).
Thanks for your persistence!
Dirk

John Pletka

unread,
Aug 5, 2010, 9:23:03 AM8/5/10
to play-fr...@googlegroups.com
HTML Output:
<!-- press-css: main.css -->
<!-- press-css: reports.css -->
<link href="/press.press/getcompressedcss?key=WYgFWeDnSTdBROQHYppDxgJJ.css" rel="stylesheet" type="text/css" charset="utf-8" ></link>

Error in Console:

Listening for transport dt_socket at address: 8000
09:21:18,374 INFO ~ Starting D:\playtest\playtest3
09:21:18,374 INFO ~ Module press is available (D:\play-1.1-unstable-r982\modules\press-1.0.1)
09:21:20,421 WARN ~ You're running Play! in DEV mode
09:21:20,577 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
09:21:23,374 INFO ~ Application 'playtest' is now started !
09:21:25,952 ERROR ~
@63cl09gi0
Internal Server Error (500) for request GET /press.press/getcompressedcss?key=WYgFWeDnSTdBROQHYppDxgJJ.css
Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException: Your file does not exists (D:\playtest\playtest3\public\stylesheets\press\WGfctEXYbWVFjNOgNRraGwJJ.css)
play.exceptions.UnexpectedException: Unexpected Error
at play.mvc.results.RenderBinary.apply(RenderBinary.java:162)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:276)
at Invocation.HTTP Request(Play!)
Caused by: play.exceptions.UnexpectedException: Your file does not exists (D:\playtest\playtest3\public\stylesheets\press\WGfctEXYbWVFjNOgNRraGwJJ.css)
at play.mvc.results.RenderBinary.apply(RenderBinary.java:135)
... 2 more

dirk

unread,
Aug 5, 2010, 9:44:44 AM8/5/10
to play-fr...@googlegroups.com
Could you please set your log level to TRACE in application.conf (look for the line like this: "# application.log=INFO" and change it to "application.log=TRACE"). Press will output a bunch of debug info saying what it's doing, with each line prefixed with the word "Press: ".
Please send anything relevant you find.
Thanks again!
Dirk
Reply all
Reply to author
Forward
0 new messages