scalajs-bundler icon indicating copy to clipboard operation
scalajs-bundler copied to clipboard

webpack-dev-server doesn't serve files from root

Open nornagon opened this issue 7 years ago • 4 comments

The static example and other examples of using scalajs-bundler generally have an index.html at the root directory, with a script tag like <script src="target/scala-2.12/scalajs-bundler/main/pcgtest-fastopt-bundle.js">. But the webpack dev server serves files from the npm directory, so there's no way to have that index.html served up by webpack-dev-server, that I can see.

nornagon avatar Jul 19 '17 15:07 nornagon

To work around this:

webpackDevServerExtraArgs in fastOptJS ++= Seq(
  "--content-base",
  (baseDirectory in ThisBuild).value.getAbsolutePath
)

nornagon avatar Jul 19 '17 16:07 nornagon

@MasseGuillaume What’s the behaviour now that #176 has been merged?

julienrf avatar Sep 22 '17 14:09 julienrf

It does not. You need to add contentBase. However, this is only for static assets.

MasseGuillaume avatar Sep 22 '17 15:09 MasseGuillaume

If you use a custom webpack config you can even serve multiple directories by passing an array of absolute paths to contentBase. This works well for me. AFAIK you cannot do that with the cli switch.

fdietze avatar Sep 22 '17 15:09 fdietze