Skip to content

Commit

Permalink
Bundle fonts with web assets lsug#27
Browse files Browse the repository at this point in the history
  • Loading branch information
Olga Mazhara committed Jan 17, 2021
1 parent 584ba63 commit 7f81163
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 11 additions & 6 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import $file.webpack
import $file.reboot

import ammonite.ops.mkdir
import mill._
import scalalib._
import scalafmt._
import mill.scalajslib._
import webpack.{WebpackModule, NpmDependency}
import webpack.{NpmDependency, WebpackModule}
import $file.fonts

val catsEffectDep = ivy"org.typelevel::cats-effect::2.3.0"

Expand Down Expand Up @@ -52,7 +53,7 @@ object protocolJs extends ProtocolModule with ScalaJSModule {

object protocolJvm extends ProtocolModule

object server extends ScalaModule {
object server extends ScalaModule with fonts.FontDownloader {

def scalaVersion = "2.13.1"
def moduleDeps = Seq(protocolJvm)
Expand Down Expand Up @@ -96,10 +97,16 @@ object server extends ScalaModule {
millSourcePath / "src" / "main" / "resources" / "localkey.pkcs12"
}


override def compile = T {
getFonts()
super.compile()
}
object test extends Tests {
def ivyDeps = Agg(ivy"org.scalameta::munit::0.7.19")
def testFrameworks = Seq("munit.Framework")
}

}

object client extends ScalaJSModule {
Expand Down Expand Up @@ -157,7 +164,6 @@ object web extends WebModule {
val r0 = r(t0).map(_.asInstanceOf[PathRef])
val r1 = r(t1).map(_.asInstanceOf[PathRef])
val r2 = r(t2).map(_.asInstanceOf[PathRef])

(r0, r1, r2) match {
case (
Result.Success(bundle),
Expand All @@ -184,7 +190,6 @@ object web extends WebModule {
val r0 = r(t0).map(_.asInstanceOf[PathRef])
val r1 = r(t1).map(_.asInstanceOf[PathRef])
val r2 = r(t2).map(_.asInstanceOf[PathRef])

(r0, r1, r2) match {
case (
Result.Success(bundle),
Expand Down Expand Up @@ -291,4 +296,4 @@ object ci extends WebModule {
def reboot() = T.command {
$file.reboot.reboot(instanceId())
}
}
}
16 changes: 16 additions & 0 deletions fonts.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import mill._
import ammonite.ops._


trait FontDownloader extends Module {

def getFonts = T {
val dest = T.ctx().dest
val fontsDir = dest / 'fonts
mkdir(fontsDir)
mill.modules.Util.downloadUnpackZip("https://github.com/adobe-fonts/source-serif-pro/releases/download/3.001R/source-serif-pro-3.001R.zip",
"source-serif-pro-3.001R")

os.copy(dest/"source-serif-pro-3.001R", fontsDir, replaceExisting = true)
}
}

0 comments on commit 7f81163

Please sign in to comment.