Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Static (and Versioned) Assets in the Client #50

Closed
michaelahlers opened this issue Apr 29, 2017 · 3 comments
Closed

Using Static (and Versioned) Assets in the Client #50

michaelahlers opened this issue Apr 29, 2017 · 3 comments

Comments

@michaelahlers
Copy link

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 and AssetsFinder 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.)

@vmunier
Copy link
Owner

vmunier commented May 3, 2017

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: vmunier/play-with-scalajs-example-javascript-router@54494bd
Let me know if that helps.

@michaelahlers
Copy link
Author

@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?

@vmunier
Copy link
Owner

vmunier commented May 5, 2017

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: playframework/playframework#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).

@vmunier vmunier closed this as completed Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants