Closed michaelahlers closed 4 years ago
Hi, I've created a separate project https://github.com/vmunier/play-with-scalajs-example-javascript-router to show how you could use JavaScript Router that supports Versioned Assets. Here's the diff of the commit: https://github.com/vmunier/play-with-scalajs-example-javascript-router/commit/54494bdeea50cde209c81305f405f8bdf0d156d6 Let me know if that helps.
@vmunier, that's extremely helpful! I'd hoped the JS router could be brought to bear here. One point worth noting: once Play 2.6 drops, it's SecurityHeadersFilter
(configured to defeat inline script
tags by default) will require a hash of the contents or a nonce provided in the response headers. I'll circle back with an example soon. On a related topic, I've commented on my original posting usage of a sbt-simple-url-update to reference versioned assets in stylesheets. It's not specific to Scala.js and I'm surprised Play doesn't document a more direct way. Any thoughts?
Indeed, there is nothing Scala.js specific. The JavaScript router provided by the Play Framework should support fingerprinted assets. The issue that guided me to the workaround presented above is: https://github.com/playframework/playframework/issues/3435. I suppose that most people do not use the JavaScript router but resolve fingerprinted assets on the server side using Twirl (routes.Assets.versioned
).
Is it possible to include static assets (namely images), served from Play and referenced from Scala.js code? Tricky because—when, for example, using sbt-digest to fingerprint assets—the final asset name isn't known. Soliciting ideas or guidance here since reverse
Assets
routes andAssetsFinder
can't be used and little on this topic turned up in my searches. (Reposted from ochrons/scalajs-spa-tutorial#65 to gather a larger audience.)