i think the problem lies somewhere in the way our folder structure is configured. our client application is located in a "client" subproject
projectroot/client
and the folder layout in there is as follows
projectroot/client/src/main/js
projectroot/client/src/main/scala
projectroot/client/webpack
projectroot/client/public
and this is the config in build.sbt to reflect that layout
webpackResources := baseDirectory.value / "webpack" * "*",
webpackConfigFile in fastLinkJS := Some(baseDirectory.value / "webpack" / "webpack-fastopt.config.js"),
webpackConfigFile in fullLinkJS := Some(baseDirectory.value / "webpack" / "webpack-opt.config.js"),
webpackConfigFile in Test := Some(baseDirectory.value / "webpack" / "webpack-core.config.js"),
webpackDevServerExtraArgs in fastLinkJS := Seq("--inline"),
webpackBundlingMode in fastLinkJS := BundlingMode.LibraryOnly(),
i succeeded in making the whole thing compile when i change the above to use fullOptJS and fastOptJS instead of the linker version. which i don't quite understand to be honest, since to documentation states to use the fast/fullLinkJS in the newest versions.
i still get the sourcemap warnings though
../../../../src/main/scala/org/...
http://localhost:9000/src/main/scala/org/...
http://host/src/*
for the browser to resolve them. Which I'm somewhat OK doing as it's only for development purposes, I can disable that route for production. But since it worked "out of the box" previously before I switched to scalajs-bundler, I thought I'd see if there's a better solution first.
Is there a write up about reducing the bundle size? Quickly scanning through this channel it's kind of a duplicate quesetion being asked... I've seen some docs Bundling mode, but I think there is more to it I think:
At the moment with fullOptJS::webpack
my bundle size is 7,2 mb (using scalajs-react, circe, endpoints4s, droste (local build)).. I guess there are transitive dependencies and maybe code which is not being used?
fullOptJS
does minify the output of Scala.js, but it doesn’t process your dependencies).
const glob = require('glob');
const purgecss = require('@fullhuman/postcss-purgecss')
module.exports = {
plugins: [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
purgecss({
content: glob.sync('../../../../**/*.scala'),
defaultExtractor: content => {
const regex = /className := "(.*?)"/g;
const result = [...content.matchAll(regex)].map(match => match[1]) || [];
return result.map(x => x.split(' ')).flat();
}
})
]
};
JSImport
but the output js remains the same
@js.native
@JSImport("ace-builds/src-noconflict/mode-scala.js", JSImport.Namespace)
object scalamode extends js.Object
scalamode
in my program entry point