LoginSignup
1
0

More than 5 years have passed since last update.

node_modules以下のライブラリをAssetsで使う

Posted at

npmで管理したくなって探してみたら出来たからメモ
もっといい方法がある気がするけど見つからなかった

  • 元々、public以下になっているのをnode_modulesにする。
build.sbt
lazy val root = (project in file(".")).enablePlugins(PlayScala)
    .settings(
        resourceDirectory in Assets := baseDirectory.value / "node_modules"
    )
  • Play 2.6になってから以下の書き方が推奨されている
application.conf
play.assets {
    path = "/public"
    urlPrefix = "/assets"
}
GET     /assets/*file               controllers.Assets.at(file)
index.scala.html
<link rel="stylesheet" href="@routes.Assets.at("bulma/css/bulma.css")">
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0