开发者

What's the best practice for including CSS and javascript files in a java web project?

I've recently started on a new google app engine project that uses RestEasy for MVC and Grad开发者_高级运维le for our build process. Now I'm at a point where I want to include SASS, javascript, and closure template files but I'm unsure about how I should do this. Ideally I'd like to satisfy the following requirements:

  1. The files should live in their own source directory. eg src/main/javascript, src/main/sass.
  2. When deploying, the javascript files should be minified.
  3. When developing, the closure templates and sass files should be watched for changes and hot-swapped into the running environment.
  4. The closure templates should be accessible by the client and server. (That way rendering can happen on either end)

What do you think is the best way to accomplish all of this? Thanks for your time.


  1. I'm placing it into src/main/webapp/js and src/main/webapp/sass (compiled to src/main/webapp/css It's pretty standard and goes well with all maven plugin

  2. There is yuicompressor-maven-plugin, it can compress js and css

  3. If you're using Compass for SASS, then it can watch and recompile out of box (-watch option). BTW, it's complicated to make hot-swapping. Instead of it I'm using local nginx in front of my gae app, it proxying all non-static request to original jetty (used by gae plugin), but serves all static files (like js, images, css) directly from src/main/webapp. It's pretty easy to configure nginx for that scenario

  4. It's the problem, and can't find any good solution for that :( So i'm trying to render this part only at client side (by using jquery-tmpl), passing all data as javascript/json, directly inside my jsp's

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜