tuplejump / play-yeoman

Play + Yeoman integration sbt and play plugins
Apache License 2.0
238 stars 57 forks source link

Unable to load scripts/css in demo app #78

Closed polymorpher closed 9 years ago

polymorpher commented 9 years ago

Following the instructions in the repository I have created a demo app that is generated by "yo angular", and commented out "'connect:livereload'" in grunt runtask. I can access http://localhost:9000/ui/ in my browser successfully. However, I get the following errors:

https://www.dropbox.com/s/onxk3oc9fh3q13n/Screenshot%202015-06-22%2001.14.12.png?dl=0

It seems scripts and css resources are not routed correctly (for everything under /ui/). Indeed, when these URL are accessed directly via the browser, I only receive empty response.

Shiti commented 9 years ago

@polymorpher are these files available when you start the ui app using grunt only? Are you able to run the demo-app? Is it possible for you to share the application code?

polymorpher commented 9 years ago

My app is based on play 2.3 + sbt so I haven't tried demo-app. I will give it a try with grunt only in a few hours. If it doesn't work I will upload the source code for my demo app

Sent from my iPhone

On Jun 22, 2015, at 9:22 PM, Shiti Saxena notifications@github.com wrote:

@polymorpher are these files available when you start the ui app using grunt only? Are you able to run the demo-app? Is it possible for you to share the application code?

— Reply to this email directly or view it on GitHub.

Shiti commented 9 years ago

I have tagged the release 0.7.1 (Play 2.3.x) so that its easier to access the demo-app for that version

polymorpher commented 9 years ago

I looked at your demo - it seems the demo does not use sbt.

To upload a sbt demo project I created a new Play 2.4 project with 0.8.0 version of the plugin. https://github.com/polymorpher/play-yeoman-demo

Now I am stuck at routing error: https://www.dropbox.com/s/djl00z6b4hzfoz2/Screenshot%202015-06-23%2000.51.38.png?dl=0

I am sure there is something wrong with build.sbt. It seems the way to make it work is different from version to version (Play 2.2.x v.s. Play 2.3.x v.s. Play 2.4.x). Some clear documentation would be greatly helpful.

Shiti commented 9 years ago

The demo uses sbt.

Can you share your build file?

polymorpher commented 9 years ago

My mistake then. I did not find build.sbt at first glance.

https://github.com/polymorpher/play-yeoman-demo/blob/master/build.sbt

Shiti commented 9 years ago

The build.sbt should be like

import com.tuplejump.sbt.yeoman.Yeoman

name := "yo-demo"

version := "2.0.0"

scalaVersion := "2.11.6"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

Yeoman.yeomanSettings ++ Yeoman.withTemplates

I have updated the README and the demo-app now uses a build.sbt file instead.

polymorpher commented 9 years ago

Thanks. I tried that, still getting the same error: [error] /Users/polymorpher/idea/yo-demo/conf/routes:11: type Yeoman is not a member of package com.tuplejump.playYeoman [error] GET /ui com.tuplejump.playYeoman.Yeoman.index

Shiti commented 9 years ago

@polymorpher can you try again after executing sbt clean? If the error persists, please share the logs. It will be helpful if you can share the project code.

polymorpher commented 9 years ago

Yeah, I tried sbt clean. The error occurs when I execute sbt compile. The code is available at https://github.com/polymorpher/play-yeoman-demo

polymorpher commented 9 years ago

It seems the previous error was caused by an incorrect sbt version (had 0.13.7 on this computer). After I upgraded sbt to 0.13.8, the error disappears, but the same errors in the browser are still there.

https://www.dropbox.com/s/onxk3oc9fh3q13n/Screenshot%202015-06-22%2001.14.12.png?dl=0

Shiti commented 9 years ago

@polymorpher By default, play-yeoman utilizes files from ui/.tmp and ui/app (assuming bower_components is in ui/app. In your application, the bower_components is in ui. So, you need to modify the Yeoman setting devDirs from

yeoman.devDirs=["ui/.tmp", "ui/app"]

to

yeoman.devDirs=["ui/.tmp", "ui/app","ui"]
polymorpher commented 9 years ago

It works! Many thanks. Now the only thing missing is the stylesheet:

https://www.dropbox.com/s/dkslwrzly5n9x8b/Screenshot%202015-06-25%2001.57.45.png?dl=0

Shiti commented 9 years ago

@polymorpher Please check if you have made any changes to the stylesheet there could be a typo. Since the code from your repo works for me.

app

polymorpher commented 9 years ago

Okay, the error was a result of the absence of ruby, compass - grunt build was not successful, therefore main.scss is not "compiled" to main.css, and scripts were not copied to ui/.tmp.

Installing ruby, compass, and executing "grunt build" prior to executing "sbt run" again resolves the problem.

Thanks for your help!

BasitAli commented 9 years ago

IMO, this should be pinned or added to the wiki. Ran into the same issue on a fresh setup. Thanks for the solutions.

Shiti commented 9 years ago

@basitali This issue has been resolved in 0.8.1