Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

play 2.3 sbt-concat not working in prod

I want to use this plugin

addSbtPlugin("net.ground5hark.sbt" % "sbt-concat" % "0.1.8")

To concatenate my assets.

I have 3 groups :

Concat.groups := Seq(
  "concat_main.css" -> group(Seq(
    "stylesheets/bootstrap.min.css",
    "stylesheets/font-awesome.css",
    "stylesheets/totem/sidebar/component.css",
    "stylesheets/main.min.css"
  )),
  "concat_main.js" -> group(Seq(
    "javascripts/jquery-2.1.0.min.js",
    "javascripts/bootstrap.min.js",
    "javascripts/totemPage/sidebar/modernizr.custom.js",
    "javascripts/totemPage/respond.min.js",
    "javascripts/totemPage/html5shiv.js",
    "javascripts/totemPage/sidebar/classie.js",
    "javascripts/main.js"
  )),
  "concat_noel.js" -> group(Seq(
    "javascripts/totemPage/ouibounce-modal.js",
    "javascripts/ouibounce_modal.js",
    "javascripts/homePage.js",
    "javascripts/totemPage/jquery.cookie.js",
    "javascripts/embed.js"
  ))
)

Concat.parentDir := "public/main/javascripts"

pipelineStages in Assets := Seq(concat, uglify, digest, gzip)

Files are generated in dev, I can access

<link rel="stylesheet" href="@routes.Assets.versioned("javascripts/concat_main.css")">
<script src="@routes.Assets.versioned("javascripts/concat_main.js")" type="text/javascript"></script>

But with activator start I have a 404.

like image 917
Julien D Avatar asked Nov 27 '14 14:11

Julien D


1 Answers

At the sbt-web documentation you can read that:

If you have some need for the assets produced by the pipelineStages in your development environment (during play run), then you can scope the pipelineStages to the Assets config.

pipelineStages in Assets := Seq(myPipelineTask)

And this is what you have done which is setting the pipelineStages key scoped to the Assets configuration. However, this works only for the development mode. In order to run the pipeline in the production mode you have to set the pipelineStages key scoped to the Global configuration. In your case this will look like this:

pipelineStages := Seq(concat, uglify, digest, gzip)
like image 139
Daniel Olszewski Avatar answered Oct 11 '22 11:10

Daniel Olszewski