-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ target/ | |
project/target/ | ||
.idea/ | ||
|
||
.bsp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-J-Xmx4G | ||
-J-XX:MaxMetaspaceSize=4G | ||
-J-XX:+CMSClassUnloadingEnabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,89 @@ | ||
import chrome._ | ||
import chrome.permissions.Permission | ||
import chrome.permissions.Permission.API | ||
import com.alexitc.{Chrome, ChromeSbtPlugin} | ||
|
||
resolvers += Resolver.sonatypeRepo("releases") | ||
resolvers += Resolver.bintrayRepo("oyvindberg", "ScalablyTyped") | ||
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" | ||
|
||
name := "chrome-scalajs-template" // TODO: REPLACE ME | ||
version := "1.0.0" | ||
scalaVersion := "2.12.10" | ||
scalacOptions ++= Seq( | ||
"-language:implicitConversions", | ||
"-language:existentials", | ||
"-Xlint", | ||
"-deprecation", | ||
//"-Xfatal-warnings", | ||
"-feature" | ||
) | ||
|
||
enablePlugins(ChromeSbtPlugin, BuildInfoPlugin, ScalaJSBundlerPlugin, ScalablyTypedConverterPlugin) | ||
import com.alexitc.ChromeSbtPlugin | ||
|
||
lazy val appName = "chrome-scalajs-template" // TODO: REPLACE ME | ||
lazy val isProductionBuild = sys.env.getOrElse("PROD", "false") == "true" | ||
|
||
// build-info | ||
buildInfoPackage := "com.alexitc" | ||
buildInfoKeys := Seq[BuildInfoKey](name) | ||
buildInfoKeys ++= Seq[BuildInfoKey]( | ||
"production" -> (sys.env.getOrElse("PROD", "false") == "true") | ||
) | ||
|
||
// NOTE: source maps are disabled to avoid a file not found error which occurs when using the current | ||
// webpack settings. | ||
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withSourceMap(false) | ||
version in webpack := "4.8.1" | ||
|
||
webpackConfigFile := { | ||
val file = if (isProductionBuild) "production.webpack.config.js" else "dev.webpack.config.js" | ||
Some(baseDirectory.value / file) | ||
} | ||
|
||
// scala-js-chrome | ||
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase( | ||
Some((Compile / fastOptJS / artifactPath).value.toURI) | ||
) | ||
skip in packageJSDependencies := false | ||
|
||
webpackBundlingMode := BundlingMode.Application | ||
|
||
fastOptJsLib := (webpack in (Compile, fastOptJS)).value.head | ||
fullOptJsLib := (webpack in (Compile, fullOptJS)).value.head | ||
|
||
webpackBundlingMode := BundlingMode.LibraryAndApplication() | ||
val circe = "0.13.0" | ||
|
||
// you can customize and have a static output name for lib and dependencies | ||
// instead of having the default files names like extension-fastopt.js, ... | ||
artifactPath in (Compile, fastOptJS) := { | ||
(crossTarget in (Compile, fastOptJS)).value / "main.js" | ||
lazy val baseSettings: Project => Project = { | ||
_.enablePlugins(ScalaJSPlugin) | ||
.settings( | ||
name := appName, | ||
version := "1.0.0", | ||
scalaVersion := "2.13.3", | ||
scalacOptions ++= Seq( | ||
"-language:implicitConversions", | ||
"-language:existentials", | ||
"-Xlint", | ||
"-deprecation", // Emit warning and location for usages of deprecated APIs. | ||
"-encoding", | ||
"utf-8", // Specify character encoding used by source files. | ||
"-explaintypes", // Explain type errors in more detail. | ||
"-feature", // Emit warning and location for usages of features that should be imported explicitly. | ||
"-unchecked" // Enable additional warnings where generated code depends on assumptions. | ||
), | ||
scalacOptions += "-Ymacro-annotations", | ||
requireJsDomEnv in Test := true | ||
) | ||
} | ||
|
||
artifactPath in (Compile, fullOptJS) := { | ||
(crossTarget in (Compile, fullOptJS)).value / "main.js" | ||
lazy val bundlerSettings: Project => Project = { | ||
_.enablePlugins(ScalaJSBundlerPlugin) | ||
.settings( | ||
// NOTE: source maps are disabled to avoid a file not found error which occurs when using the current | ||
// webpack settings. | ||
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withSourceMap(false), | ||
version in webpack := "4.8.1", | ||
webpackConfigFile := { | ||
val file = if (isProductionBuild) "production.webpack.config.js" else "dev.webpack.config.js" | ||
Some(baseDirectory.value / file) | ||
}, | ||
// scala-js-chrome | ||
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase( | ||
Some((Compile / fastOptJS / artifactPath).value.toURI) | ||
), | ||
skip in packageJSDependencies := false, | ||
webpackBundlingMode := BundlingMode.Application, | ||
fastOptJsLib := (webpack in (Compile, fastOptJS)).value.head, | ||
fullOptJsLib := (webpack in (Compile, fullOptJS)).value.head, | ||
webpackBundlingMode := BundlingMode.LibraryAndApplication(), | ||
// you can customize and have a static output name for lib and dependencies | ||
// instead of having the default files names like extension-fastopt.js, ... | ||
artifactPath in (Compile, fastOptJS) := { | ||
(crossTarget in (Compile, fastOptJS)).value / "main.js" | ||
}, | ||
artifactPath in (Compile, fullOptJS) := { | ||
(crossTarget in (Compile, fullOptJS)).value / "main.js" | ||
} | ||
) | ||
} | ||
|
||
chromeManifest := new ExtensionManifest { | ||
override val name = "__MSG_extensionName__" // NOTE: i18n on the manifest is not supported on firefox | ||
override val version = Keys.version.value | ||
|
||
override val description = Some( | ||
"TO BE UPDATED" // TODO: REPLACE ME | ||
) | ||
override val icons = Chrome.icons("icons", "app.png", Set(48, 96, 128)) | ||
|
||
// TODO: REPLACE ME, use only the minimum required permissions | ||
override val permissions = Set[Permission]( | ||
API.Storage, | ||
API.Notifications, | ||
API.Alarms | ||
) | ||
|
||
override val defaultLocale: Option[String] = Some("en") | ||
|
||
// TODO: REPLACE ME | ||
override val browserAction: Option[BrowserAction] = | ||
Some(BrowserAction(icons, Some("TO BE DEFINED - POPUP TITLE"), Some("popup.html"))) | ||
|
||
// scripts used on all modules | ||
val commonScripts = List("scripts/common.js", "main-bundle.js") | ||
|
||
override val background = Background( | ||
scripts = commonScripts ::: List("scripts/background-script.js") | ||
) | ||
|
||
override val contentScripts: List[ContentScript] = List( | ||
ContentScript( | ||
matches = List( | ||
"https://github.com/*" // TODO: REPLACE ME | ||
lazy val buildInfoSettings: Project => Project = { | ||
_.enablePlugins(BuildInfoPlugin) | ||
.settings( | ||
buildInfoPackage := "com.alexitc", | ||
buildInfoKeys := Seq[BuildInfoKey](name), | ||
buildInfoKeys ++= Seq[BuildInfoKey]( | ||
"production" -> isProductionBuild | ||
), | ||
css = List("css/active-tab.css"), | ||
js = commonScripts ::: List("scripts/active-tab-script.js") | ||
buildInfoUsePackageAsPath := true | ||
) | ||
) | ||
|
||
override val webAccessibleResources = List("icons/*") | ||
} | ||
|
||
val circe = "0.13.0" | ||
|
||
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" | ||
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % "0.7.0" | ||
|
||
libraryDependencies += "io.circe" %%% "circe-core" % circe | ||
libraryDependencies += "io.circe" %%% "circe-generic" % circe | ||
libraryDependencies += "io.circe" %%% "circe-parser" % circe | ||
|
||
// js dependencies, adding typescript type definitions gets them a Scala facade | ||
npmDependencies in Compile ++= Seq( | ||
"sweetalert" -> "2.1.2" | ||
) | ||
lazy val root = (project in file(".")) | ||
.enablePlugins(ChromeSbtPlugin, ScalablyTypedConverterPlugin) | ||
.configure(baseSettings, bundlerSettings, buildInfoSettings) | ||
.settings( | ||
chromeManifest := AppManifest.generate(appName, Keys.version.value), | ||
// js dependencies, adding typescript type definitions gets them a Scala facade | ||
Compile / npmDependencies ++= Seq( | ||
"sweetalert" -> "2.1.2" | ||
), | ||
libraryDependencies ++= Seq( | ||
"org.scala-js" %%% "scalajs-dom" % "1.1.0", | ||
"com.alexitc" %%% "scala-js-chrome" % "0.7.0", | ||
"io.circe" %%% "circe-core" % circe, | ||
"io.circe" %%% "circe-generic" % circe, | ||
"io.circe" %%% "circe-parser" % circe | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import chrome.permissions.Permission | ||
import chrome.permissions.Permission.API | ||
import chrome.{Background, BrowserAction, ContentScript, ExtensionManifest} | ||
import com.alexitc.Chrome | ||
|
||
object AppManifest { | ||
|
||
def generate(appName: String, appVersion: String): ExtensionManifest = { | ||
new ExtensionManifest { | ||
override val name = appName | ||
override val version = appVersion | ||
|
||
override val description = Some( | ||
"TO BE UPDATED" // TODO: REPLACE ME | ||
) | ||
override val icons = Chrome.icons("icons", "app.png", Set(48, 96, 128)) | ||
|
||
// TODO: REPLACE ME, use only the minimum required permissions | ||
override val permissions = Set[Permission]( | ||
API.Storage, | ||
API.Notifications, | ||
API.Alarms | ||
) | ||
|
||
override val defaultLocale: Option[String] = Some("en") | ||
|
||
// TODO: REPLACE ME | ||
override val browserAction: Option[BrowserAction] = | ||
Some(BrowserAction(icons, Some("TO BE DEFINED - POPUP TITLE"), Some("popup.html"))) | ||
|
||
// scripts used on all modules | ||
val commonScripts = List("scripts/common.js", "main-bundle.js") | ||
|
||
override val background = Background( | ||
scripts = commonScripts ::: List("scripts/background-script.js") | ||
) | ||
|
||
override val contentScripts: List[ContentScript] = List( | ||
ContentScript( | ||
matches = List( | ||
"https://github.com/*" // TODO: REPLACE ME | ||
), | ||
css = List("css/active-tab.css"), | ||
js = commonScripts ::: List("scripts/active-tab-script.js") | ||
) | ||
) | ||
|
||
override val webAccessibleResources = List("icons/*") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version = 1.3.13 | ||
sbt.version=1.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters