Skip to content

Commit

Permalink
added webpack support
Browse files Browse the repository at this point in the history
  • Loading branch information
abuntakov committed Apr 4, 2016
1 parent a0eb653 commit 9a577bc
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 4,696 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"semi": [2, "always"]
},

"ecmaFeatures": {
"modules": true
},

"env": {
"es6": true,
"browser": true,
Expand Down
1 change: 1 addition & 0 deletions app/views/main.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta charset="UTF-8">
<title>Hello world</title>
<link rel="stylesheet" href='@routes.Assets.versioned("styles.css")'>
<script src='@routes.Assets.versioned("app-main.js")'></script>
</head>
<body>
<div class="container">
Expand Down
12 changes: 12 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import play.sbt.PlayImport.PlayKeys.playRunHooks

playRunHooks += Webpack(baseDirectory.value)

// lazy val webpack = Webpack.dist(baseDirectory.value)
val webpack = taskKey[Unit]("Webpack task")

webpack := Webpack.dist(baseDirectory.value)

lazy val commonSettings = Seq(
organization := "org.sample",
version := "0.0.1",
Expand All @@ -19,6 +24,13 @@ libraryDependencies ++= Seq(
"org.flywaydb" %% "flyway-play" % "3.0.0",
"ch.qos.logback" % "logback-classic" % "1.1.6")

stage <<= stage dependsOn webpack

cleanFiles <+= baseDirectory { base => base / "public" }

pipelineStages := Seq(digest, gzip)


lazy val root = (project in file("."))
.settings(commonSettings:_*)
.enablePlugins(PlayScala)
Expand Down
2 changes: 2 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ db.default.url="jdbc:postgresql://localhost:5432/play"
db.default.user=postgres
db.default.password=secret

play.crypto.secret="y2qXEm?Ty2oDwn]Lz9XOIblsbF2D>TX3sP@?1J`V40GkasXGcEYKdZSMJlN>R_3i"

scalikejdbc.global.loggingSQLAndTime.enable=true
scalikejdbc.global.loggingSQLAndTime.singleLineMode=false
scalikejdbc.global.loggingSQLAndTime.logLevel=debug
Expand Down
6 changes: 6 additions & 0 deletions frontend/applications/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class Point {
constructor(posX, posY) {
this.locationX = posX;
this.locationY = posY;
}
}
15 changes: 10 additions & 5 deletions project/Webpack.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ object Webpack {
var process: Option[Process] = None

override def beforeStarted(): Unit = {
Process("webpack", base).run
}

override def afterStarted(addr: InetSocketAddress): Unit = {
process = Some(Process("webpack --watch", base).run)
Process("webpack --watch", base).run
}

override def afterStopped(): Unit = {
Expand All @@ -24,4 +20,13 @@ object Webpack {

WebpackProcess
}

def dist(base: File) = {
val process: ProcessBuilder = Process("webpack", base, "PROD_ENV" -> "true")
println(s"Will run: ${process.toString} in ${base.getPath}")
process.run().exitValue() match {
case 0 => 0
case code => throw new Exception(s"webpack failed with code=$code")
}
}
}
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")

addSbtPlugin("org.flywaydb" % "flyway-sbt" % "3.2.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")

resolvers += "Flyway" at "https://flywaydb.org/repo"
1 change: 1 addition & 0 deletions public/app-main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 0 additions & 90 deletions public/main.js

This file was deleted.

1 change: 1 addition & 0 deletions public/style.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a577bc

Please sign in to comment.