@@ -21,54 +21,36 @@ lazy val commonSettings = Seq(
21
21
)
22
22
23
23
lazy val jsSettings = Seq (
24
- webpack / version := " 4.46.0" ,
25
- useYarn := true ,
26
24
scalaJSLinkerConfig ~= { _.withOptimizer(false ) },
27
25
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind .CommonJSModule ) },
28
26
libraryDependencies += " org.portable-scala" %%% " portable-scala-reflect" % " 1.1.2" ,
27
+ externalNpm := {
28
+ sys.process.Process (" yarn" , baseDirectory.value).!
29
+ baseDirectory.value
30
+ },
29
31
)
30
32
31
- def readJsDependencies (baseDirectory : File , field : String ): Seq [(String , String )] = {
32
- val packageJson = ujson.read(IO .read(new File (s " $baseDirectory/package.json " )))
33
- packageJson(field).obj.mapValues(_.str.toString).toSeq
34
- }
35
-
36
33
lazy val webapp = project
37
34
.enablePlugins(
38
35
ScalaJSPlugin ,
39
- ScalaJSBundlerPlugin ,
40
- ScalablyTypedConverterPlugin ,
36
+ ScalablyTypedConverterExternalNpmPlugin ,
41
37
)
42
38
.dependsOn(api)
43
39
.settings(commonSettings, jsSettings)
44
40
.settings(
45
- libraryDependencies ++= Seq (
41
+ libraryDependencies ++= Seq (
46
42
" io.github.outwatch" %%% " outwatch" % versions.outwatch,
47
43
" io.github.fun-stack" %%% " fun-stack-web" % versions.funStack,
48
44
" io.github.fun-stack" %%% " fun-stack-web-tapir" % versions.funStack, // this pulls in scala-java-time, which will drastically increase the javascript bundle size. Remove if not needed.
49
45
" com.github.cornerman" %%% " colibri-router" % versions.colibri,
50
46
" io.suzaku" %%% " boopickle" % versions.boopickle,
51
47
),
52
- Compile / npmDependencies ++= readJsDependencies(baseDirectory.value, " dependencies" ) ++ Seq (
53
- " snabbdom" -> " github:outwatch/snabbdom.git#semver:0.7.5" , // for outwatch, workaround for: https://github.com/ScalablyTyped/Converter/issues/293
54
- " reconnecting-websocket" -> " 4.1.10" , // for fun-stack websockets, workaround for https://github.com/ScalablyTyped/Converter/issues/293 https://github.com/cornerman/mycelium/blob/6f40aa7018276a3281ce11f7047a6a3b9014bff6/build.sbt#74
55
- " jwt-decode" -> " 3.1.2" , // for fun-stack auth, workaround for https://github.com/ScalablyTyped/Converter/issues/293 https://github.com/cornerman/mycelium/blob/6f40aa7018276a3281ce11f7047a6a3b9014bff6/build.sbt#74
56
- ),
57
- stIgnore ++= List (
48
+ stIgnore ++= List (
58
49
" reconnecting-websocket" ,
59
50
" snabbdom" ,
60
51
" jwt-decode" ,
61
52
),
62
- Compile / npmDevDependencies ++= readJsDependencies(baseDirectory.value, " devDependencies" ),
63
- scalaJSUseMainModuleInitializer := true ,
64
- webpackDevServerPort := 12345 ,
65
- webpackDevServerExtraArgs := Seq (" --color" ),
66
- startWebpackDevServer / version := " 3.11.3" ,
67
- fullOptJS / webpackEmitSourceMaps := true ,
68
- fastOptJS / webpackEmitSourceMaps := true ,
69
- fastOptJS / webpackBundlingMode := BundlingMode .LibraryOnly (),
70
- fastOptJS / webpackConfigFile := Some (baseDirectory.value / " webpack.config.dev.js" ),
71
- fullOptJS / webpackConfigFile := Some (baseDirectory.value / " webpack.config.prod.js" ),
53
+ scalaJSUseMainModuleInitializer := true ,
72
54
)
73
55
74
56
// shared project which contains api definitions.
@@ -87,13 +69,12 @@ lazy val api = project
87
69
lazy val lambda = project
88
70
.enablePlugins(
89
71
ScalaJSPlugin ,
90
- ScalaJSBundlerPlugin ,
91
- ScalablyTypedConverterPlugin ,
72
+ ScalablyTypedConverterExternalNpmPlugin ,
92
73
)
93
74
.dependsOn(api)
94
75
.settings(commonSettings, jsSettings)
95
76
.settings(
96
- libraryDependencies ++= Seq (
77
+ libraryDependencies ++= Seq (
97
78
" io.github.fun-stack" %%% " fun-stack-lambda-ws-event-authorizer" % versions.funStack,
98
79
" io.github.fun-stack" %%% " fun-stack-lambda-ws-rpc" % versions.funStack,
99
80
" io.github.fun-stack" %%% " fun-stack-lambda-http-rpc" % versions.funStack,
@@ -102,27 +83,14 @@ lazy val lambda = project
102
83
" io.suzaku" %%% " boopickle" % versions.boopickle,
103
84
" com.lihaoyi" %%% " pprint" % versions.pprint,
104
85
),
105
- Compile / npmDependencies ++= readJsDependencies(baseDirectory.value, " dependencies" ),
106
- stIgnore ++= List (
86
+ stIgnore ++= List (
107
87
" aws-sdk" ,
108
88
),
109
- Compile / npmDevDependencies ++= readJsDependencies(baseDirectory.value, " devDependencies" ),
110
- fullOptJS / webpackEmitSourceMaps := true ,
111
- fastOptJS / webpackEmitSourceMaps := true ,
112
- fastOptJS / webpackConfigFile := Some (baseDirectory.value / " webpack.config.dev.js" ),
113
- fullOptJS / webpackConfigFile := Some (baseDirectory.value / " webpack.config.prod.js" ),
114
89
)
115
90
116
- addCommandAlias(" prod" , " fullOptJS/webpack" )
117
- addCommandAlias(" prodf" , " webapp/fullOptJS/webpack" )
118
- addCommandAlias(" prodb" , " lambda/fullOptJS/webpack" )
119
- addCommandAlias(" dev" , " devInitAll; devWatchAll; devDestroyFrontend" )
120
- addCommandAlias(" devf" , " devInitFrontend; devWatchFrontend; devDestroyFrontend" ) // compile only frontend
121
- addCommandAlias(" devb" , " devInitBackend; devWatchBackend" ) // compile only backend
122
- addCommandAlias(" devInitBackend" , " lambda/fastOptJS/webpack" )
123
- addCommandAlias(" devInitFrontend" , " webapp/fastOptJS/startWebpackDevServer; webapp/fastOptJS/webpack" )
124
- addCommandAlias(" devInitAll" , " devInitFrontend; devInitBackend" )
125
- addCommandAlias(" devWatchFrontend" , " ~; webapp/fastOptJS" )
126
- addCommandAlias(" devWatchBackend" , " ~; lambda/fastOptJS" )
127
- addCommandAlias(" devWatchAll" , " ~; lambda/fastOptJS; webapp/fastOptJS" )
128
- addCommandAlias(" devDestroyFrontend" , " webapp/fastOptJS/stopWebpackDevServer" )
91
+ addCommandAlias(" prod" , " fullOptJS" )
92
+ addCommandAlias(" prodf" , " webapp/fullOptJS" )
93
+ addCommandAlias(" prodb" , " lambda/fullOptJS" )
94
+ addCommandAlias(" dev" , " ~; lambda/fastOptJS; webapp/fastOptJS" )
95
+ addCommandAlias(" devf" , " ~; webapp/fastOptJS" )
96
+ addCommandAlias(" devb" , " ~; lambda/fastOptJS" )
0 commit comments