Closed milliondreams closed 8 years ago
I think my problem was caused by the fact that I put all my view files into the ui/app/views
folder (as opposed to just ui/app
) and so the Grunt htmlmin
task did not process and copy them to the target folder...
@kompot are you doing something similar? Maybe we can give some hint when you share the log output of your grunt
run.
@milliondreams @kompot
I am a little bit stuck right now as I don't know whether it is possible to achieve what I am trying to do. Maybe I am just a victim of a misunderstanding (-;
What needs to be done in my case:
/
: serve my app's "landing page"./app
: serve the app itself which is only accessible to authenticated users.In both cases, I need to be able to inject some server-side data into the HTML pages (e.g. data about the currently logged in user). Also, both pages contain links to (different) stylesheet and JavaScript files (they both contain an AngularJS application), which means they should be processed by Grunt so that those files get concatenated and minified for production mode.
What I currently don't seem to understand: is it possible to use a server-rendered template from the ui/dist
directory?
I put together a simple demo app based on the installation instructions for play-yeoman and yo-demo. It contains following routes:
/demo1
: maps to Scala template ui/app/views/demo1.scala.html
-> is served by Application
controller, so in production mode, it won't serve the file from ui/dist
, but rather ui/app/views
. Also, ui/dist/views/demo1.scala.html
won't be processed by Grunt (may be due to missing setting in Gruntfile)./demo2
: maps to Scala template ui/app/demo2.scala.html
-> will be processed by Grunt, but again, it will of course be served out of ui/app
, not ui/dist
./demo3
: maps to HTML template ui/app/demo3.html
-> this will served by Yeoman
controller, so it will be correctly processed and served from ui/dist
, but obviously, it is not rendered by the server, so it won't be possible to inject server data into it.Any ideas on how to restructure my project in order to achieve what I need?
Thanks for your support and greets.
@jtammen
Thanks a lot for the problem explanation and the sample app.
Some background -
So in conclusion we should be able to set different "unmanagedDirectories" settings while in "run" and "dist/stage" @sbt
I am not sure how to do this yet! Will be great if anyone has any knowledge about this.
Hey @milliondreams, thanks for the explanation.
Phew, sounds as if there is no easy solution for this problem ... and unfortunately, I have really close to zero knowledge about sbt, so I won't be of any help here :-/
Could I use @kompot's workaround to temporarily "fix" this and create a deployable distribution of my app? Or maybe I should switch back to pure client-side templates and fetch all data needed from the server via separate calls to my backend...
@milliondreams Any idea how to fix or work around this? I am currently a bit lost, as I need to create a deployable version of my app soon...
@jtammen You could override the settings in your project's build file as per kompot's workaround before you use dist to create a build.
Apologies as I am neck deep in some other things, so will not be able to give a timely fix here!
@milliondreams Never mind, I really appreciate all of your precious time you are putting into this very helpful project!
I will try @kompot's workaround – thanks for your feedback.
Another important point here is that the grunt build needs to complete before the play template compilation starts otherwise some or all the processed templates won't be in the dist folder yet.
Any update on this topic? I managed to create a working distribution of my app using @kompot's workaround, i.e. swap "app" with "dist" in the settings–but this is just a workaround, as it forces me to make changes to my Build.scala
when I need to create a release...
Is there any possibility this issue will be fixed? If not, is there any other option to combine sever-rendered Scala templates and the client-side templates managed by yeoman/grunt?
@jtammen Sorry I haven't got around to work on play-yeoman for a while. Things loaded at work.
Does anyone out there have any idea how to set different settings for dist task and the run/stage task???
@jtammen @kompot
This should be solved in the new release. 0.7.0
:+1: Will have a look at this soon, thanks!
BTW, with 0.7.1-SNAPSHOT, this issue remains. I can get templates for "dist" but not for dev mode.
From, 0.9.0, templates are generated on compile.
@kompot @jtammen
This is following the comment - https://github.com/tuplejump/play-yeoman/issues/12#issuecomment-32167677
I am assuming that you have index.scala.html and it is getting compiled as a play view but not being processed by Grunt? Is my assumption correct?
Can you share a sample app for me to try out and debug the issue?