Open udalrich opened 8 years ago
may you try to run activator clean compile dist" then
activator universal:packageBin`?
And may you try to add .as("text/html; charset=UTF-8")
after ok(views.html.index.render())
and try if its OK, and btw what your playframework version inside plugins.sbt file? because I think downloading index file instead of serving it a known bug for version 2.5.3
I was trying to use index.html as my source, not index.scala.html. When I changed my routes file to include
GET /ui/index.html controllers.HomeController.index()
GET /index.html controllers.HomeController.index()
GET / controllers.HomeController.index()
#GET / com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base = "/ui/")
and updated the code instead, it worked. However, now I having problems serving the processed javascript.
The project-assets.jar
file has
public/app/assets/javascripts/main.js
public/assets/images/favicon.png
public/assets/stylesheets/main.css
and is giving 404 errors trying to serve the files from /ui. Given that everything in the jar is under /public, that does not surprise me. Do I need a setting in build.sbt so that the assets are stored under ui instead of public?
I am using play 2.5.2.
projects/build.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.2")
addSbtPlugin("com.github.mmizutani" % "sbt-play-gulp" % "0.1.1")
addSbtPlugin("com.slidingautonomy.sbt" % "sbt-filter" % "1.0.1")
Sorry if its too late, I was in vacation when you replied and I saw this again when I was check my home page, for serving index (static page) may I know what inside the HomeController.index()
?
For me I just redirect the user to the index page without saying to serve index.html
something like this, inside controller:
public CompletableFuture<Result> redirectToUI(String any) {
return CompletableFuture.completedFuture(
Results.redirect("/portal/admin/").as("text/html")
);
}
Routes:
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /public/*file controllers.Assets.at(path="/public", file)
GET /favicon.ico controllers.Assets.at(path="/public/images", file="favicon.ico")
# Home page
GET /portal com.github.mmizutani.playgulp.GulpAssets.index
GET /portal/admin/*any controllers.Application.redirectToUI(any)
GET /portal/admin com.github.mmizutani.playgulp.GulpAssets.index
-> /portal/admin/ gulp.Routes
-> /portal/ gulp.Routes
GET / com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base="/portal/")
HomeController.index
is just
public Result index() {
return ok(index.render());
}
That renders and returns index.scala.html. That works for me with this routes
file:
# Files processed with gulp/babel
GET /ui/index.html controllers.HomeController.index
GET / controllers.HomeController.redirectRoot(base = "/ui/")
#GET / com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base = "/ui/")
#GET /ui com.github.mmizutani.playgulp.GulpAssets.index
-> /ui/ gulp.Routes
So you want to serve index.scala.html ? and where is that file located? and if you want to use the index of scala, why you want this plugin? could you disable it and try again?
I don't need to serve scala, but I was only able to serve a static page in dev mode. When I bundled it to deploy, it could not find the static page. As a work around, I started to serve scala.
I need to plugin to run gulp to run browserify when I serve jsx/js.
Troy
On Thu, Aug 25, 2016 at 6:06 PM, Al-Mothafar Al-Hasan < notifications@github.com> wrote:
So you want to serve index.scala.html ? and where is that file located? and if you want to use the index of scala, why you want this plugin? could you disable it and try again?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mmizutani/sbt-play-gulp/issues/16#issuecomment-242558057, or mute the thread https://github.com/notifications/unsubscribe-auth/ALnaj1eQVbaYBBlqtiWtyYCrn_29Qz5Aks5qjhHegaJpZM4JTLlq .
I have a project which is similar to the react sample. When I run in activator, it works. I have index.html in
ui/app
. When I ranactivator universal:packageBin
to create a distribution, the resulting distribution did not serve index.html.When I added
to build.sbt, it would serve index.html, but as an attachment, so the browser asked me where I wanted to save the file, rather than displaying it.
This appears to be related to the switch from dev mode to prod mode.
When I moved index.html to app/views/index.scala.html, added
to routes and implemented the method to return
ok(views.html.index.render())
, it I could load index.html when I accessed server:9000/, but it could not then load the javascript from the ui directory.Are there simple directions for making the plugin work in production mode?