{"action":"created","issue":{"url":"https://api.github.com/repos/ninjaframework/ninja/issues/321","labels_url":"https://api.github.com/repos/ninjaframework/ninja/issues/321/labels{/name}","comments_url":"https://api.github.com/repos/ninjaframework/ninja/issues/321/comments","events_url":"https://api.github.com/repos/ninjaframework/ninja/issues/321/events","html_url":"https://github.com/ninjaframework/ninja/pull/321","id":58580074,"number":321,"title":"On-The-Fly minification of js and css assets","user":{"login":"svenkubiak","id":67564,"avatar_url":"https://avatars.githubusercontent.com/u/67564?v=3","gravatar_id":"","url":"https://api.github.com/users/svenkubiak","html_url":"https://github.com/svenkubiak","followers_url":"https://api.github.com/users/svenkubiak/followers","following_url":"https://api.github.com/users/svenkubiak/following{/other_user}","gists_url":"https://api.github.com/users/svenkubiak/gists{/gist_id}","starred_url":"https://api.github.com/users/svenkubiak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenkubiak/subscriptions","organizations_url":"https://api.github.com/users/svenkubiak/orgs","repos_url":"https://api.github.com/users/svenkubiak/repos","events_url":"https://api.github.com/users/svenkubiak/events{/privacy}","received_events_url":"https://api.github.com/users/svenkubiak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-02-23T12:33:33Z","updated_at":"2015-02-27T18:57:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ninjaframework/ninja/pulls/321","html_url":"https://github.com/ninjaframework/ninja/pull/321","diff_url":"https://github.com/ninjaframework/ninja/pull/321.diff","patch_url":"https://github.com/ninjaframework/ninja/pull/321.patch"},"body":"I recently took a look at the impressive java full stuck framework wisdom (worth a look at http://wisdom-framework.org/). Wisdom has some really nice features. On of them is on On-The-Fly minification of assets. \r\n\r\nI think this could be a really good enhancement for ninja, so I created a proof of concept. Here is how it works:\r\n\r\n- I changed the WatchAndRestartMachine to check if a change on a asset (js|css) occured. \r\n- If a changed occured it will grab the content from the source file and create a new file adding min.css or min.js. Existing files will be overwritten. The JVM will not be restarted.\r\n- The idea is, that the user uses the .min.js or .min.css in the frontend, but works in the raw files.\r\n- ATM this only works in SuperDevMode, basically because as a developer I want to know, if the minification is correct.\r\n\r\nAdditional thoughts:\r\n- <strike>The current implementation assumes that you store your css in \"stylesheets\" and js in \"javascripts\", which could be a good convention, but I think it would be nice to make this configurable via the application.conf. But I did not get the injection of NinjaProperties to work (yet).</strike>\r\n-  <strike>Same goes for the outputpath, which currently is hard-coded to /src/main/java/assets </strike>\r\n\r\nUPDATE: Added configuration via application.conf\r\n\r\nLet me know, what you think.\r\n\r\nCheers,\r\nSven"},"comment":{"url":"https://api.github.com/repos/ninjaframework/ninja/issues/comments/76450665","html_url":"https://github.com/ninjaframework/ninja/pull/321#issuecomment-76450665","issue_url":"https://api.github.com/repos/ninjaframework/ninja/issues/321","id":76450665,"user":{"login":"jjlauer","id":585730,"avatar_url":"https://avatars.githubusercontent.com/u/585730?v=3","gravatar_id":"","url":"https://api.github.com/users/jjlauer","html_url":"https://github.com/jjlauer","followers_url":"https://api.github.com/users/jjlauer/followers","following_url":"https://api.github.com/users/jjlauer/following{/other_user}","gists_url":"https://api.github.com/users/jjlauer/gists{/gist_id}","starred_url":"https://api.github.com/users/jjlauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjlauer/subscriptions","organizations_url":"https://api.github.com/users/jjlauer/orgs","repos_url":"https://api.github.com/users/jjlauer/repos","events_url":"https://api.github.com/users/jjlauer/events{/privacy}","received_events_url":"https://api.github.com/users/jjlauer/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T18:57:04Z","updated_at":"2015-02-27T18:57:04Z","body":"I've been thinking about my own asset pipeline workflow in my projects and I wanted to share something I wrote which may change your thinking a bit.\r\n\r\nIt's my own \"watcher\" plugin for maven.  The idea is that rather than rely on your IDE for compiling your classes (which isn't very reliable in a large project) during SuperDevMode -- I simply wanted to open a second shell and have maven continuously trigger a \"compile\" if a source file changes.  Then I also gain the benefit of using maven's process-classes, etc. phases as it would work even outside of Ninja.\r\n\r\nhttps://github.com/fizzed/java-maven-plugins\r\n\r\nI planned on sharing this with the Ninja community in the future, but thought it was worth sharing now during this discussion.  You could actually just add onto this idea to add minification as a maven plugin during the process-classes or generate-sources phase.  This watcher plugin would simply work out-of-the-box for you and no changes needed for the SuperDevMode code. \r\n\r\nThe obvious benefit is that you can add any sort of maven plugin you need for your asset pipeline.  Same pipeline then used during SuperDevMode or if you're just packaging your app on the command line.\r\n\r\nThoughts?\r\n"}}