You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 and reverse Assets routes and AssetsFinder can't be used. Soliciting ideas or guidance here since my searches haven't turned up anything.
The text was updated successfully, but these errors were encountered:
Applying broadly to any Play project (not specific to Scala.js), the only way I've found to provide versioned assets to stylesheets and inline images involves adding a plugin which rewrites paths.
Server and client projects as illustrated by this project.
Stylesheet, owned by Play, defining classes with the content property referencing a static image in the server project à la:
img.my-logo {
/* Not widely compatible; most common case is likely to provide a background. */content:url("path/to/my-logo.png");
}
Client project assigning that class to img tags à la (VDOM in this case):
// Again, probably an uncommon usage.
img(className :="my-logo")
When staging, sbt-simple-url-update will notice the url data type in CSS file (which is itself fingerprinted) and rewrite it with the fingerprinted asset yielding:
Image appears as expected in the browser—even in production mode.
This isn't great. Have I missed anything obvious? I can't find any documentation offering a better way to reference versioned assets from CSS in a Play project.
And, while functional, this removes images from the client project (which runs afoul of locality, unless, of course, you consider it a handy way to share assets across multiple client apps. hosted by the same Play instance). I'd rather the client app. project own all its static assets (and kept close to the components referencing or styled with them).
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 and reverse
Assets
routes andAssetsFinder
can't be used. Soliciting ideas or guidance here since my searches haven't turned up anything.The text was updated successfully, but these errors were encountered: