Ditto! Harbs
> On Mar 13, 2025, at 1:58 AM, Greg Dove <greg.d...@gmail.com> wrote: > > That sounds really cool, Josh, thanks for doing that. > > On Thu, Mar 13, 2025 at 11:15 AM Josh Tynjala <joshtynj...@bowlerhat.dev> > wrote: > >> Hi folks, >> >> I just wanted to highlight some new Royale compiler options that I added >> recently. >> >> -js-include-script+=path/to/script.js >> -js-include-css+=path/to/styles.css >> -js-include-asset+=path/to/file.ext >> >> If you're building a library with compc, these options include the files >> into the .swc binary. They're stored in such a way that mxmlc will know >> that they need special processing. >> >> If you're building an app with mxmlc, these options copy the files to the >> output directory and add appropriate <script> or <link> tags to the >> generated .html file. Without requiring a custom HTML template! >> >> When using -js-include-script, the .js files go into bin/js-debug/scripts/ >> or bin/js-release/scripts/ >> >> When using -js-include-css, the .css files go into bin/js-debug/css/ or >> bin/js-release/css/ >> >> When using -js-include-asset, the files go into bin/js-debug/assets/ or >> bin/js-release/assets/ >> >> So, as example, if you want to combine -js-include-css and >> -js-include-asset together, you'd need to use appropriate relative paths >> from your .css file: >> >> background: url("../assets/image.png"); >> >> Before this change, we have mainly been using <inject_script> in asdoc >> comments for similar purposes. This allowed us to reference .js or .css >> files from web URLs. For example, FontAwesomeIcon.as has an <inject_script> >> that inserts the stylesheet from the following URL using >> document.createElement("link"): >> >> https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css >> >> There really wasn't a good way to bundle font-awesome.min.css into >> FontAwesome.swc to avoid requiring that third-party CDN or to support >> offline use, though. >> >> However, these new options now make that possible. >> >> There is one difference from <inject_script> that is worth noting. >> <inject_script> was associated with a specific class. If you didn't use >> that class in your app, the script wasn't injected. >> >> These options associate the script/css/asset with an entire .swc instead of >> specific classes in the .swc. The idea is to use them when all classes from >> the library require the script/css, and you don't need to annotate every >> single class separately. In other words, it's particularly useful for >> creating typedef/externs .swc files. >> >> I'm definitely open to adding a way to associate a script/css/asset with a >> specific class only, but I think that this is already a big improvement >> over the status quo. >> >> -- >> Josh Tynjala >> Bowler Hat LLC >> https://bowlerhat.dev/ >>