-
Notifications
You must be signed in to change notification settings - Fork 109
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
Build as a single file for use in a <script>? #20
Comments
@karx1 I'm pretty sure Rust has a way to render static files so you can try the following
That's it you can now import the build file as a script tag in your HTML and use window.(whatever you named it) to access the library/packages/module features Example, to be clearer npm-packages/index.js
bundle index.js with webpack HTML
Usage
just remember to export the path to the bundled file and import it accordingly in your HTML script tag. I usually do this when I'm working with Go using Gin Framework. |
Clone it and run <script type="module">
import flamethrower from '/path/to/main.js';
const router = flamethrower();
</script> |
You can also clone my webpack wrapper for flamethrower github.com/bennykay/flamethrower-webpack and run If you want to change options, you can do it before building in |
Or just visit this link and download the output |
Another option is to use the ESM CDN as shown here #31 |
@karx1 You could also include from unpkg, since Jeff published this to npm:
URL found via the ending-slash trick: NOTE: I haven't tried this yet, but it seems to use the standard Universal Module Definition |
Hi, I'm working on 2m2d whose webserver is written in Rust, so I can't use
npm
for the frontend (It has to be static sites only). Is there a way to build this library as a single file so I can load it in a <script> tag?The text was updated successfully, but these errors were encountered: