-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
✨ Feature – Allow script tags for CDN links and polyfills #49
Comments
🧙♂️ For context, here's the part of the Elm Land codebase that is responsible for generating the elm-land/projects/cli/src/effects.js Lines 361 to 368 in 5d3ecbc
|
@ryannhg So I have run into issues but I am also having second thoughts about the idea in the first place. But in testing I also noticed that process.env is replaced by import.meta.env. So, for people to use their own JS files they would have to buy in to Vite which is I think what you were wanting to avoid by using elm-land.json in the first place. I don't know what the right answer is, maybe only processing script tags that link to a file in static (so no imports) or URLs, and then adding a beforeReady function in interop.js for setup work. But that's just a thought. |
This plan makes sense to me– I thought the initial goal was to link to a CDN URL, rather than worrying about the NPM module. In the example shown above, we only support URLs from an existing CDN and have those be inserted into the HTML file at build time. If the Would this simple solution address the initial problem you ran into when setting up Sentry? |
Oh I see (: We don't use any CDNs but they shouldn't be hard to switch to. I have a couple pieces of code that are run before the app initialises, but I don't see any reason they can't be moved & either way allowing for URLs is a good first step. The code I linked above does work exactly the same, but it doesn't do any verification on attributes or that the script source is a URL. Is that alright? |
Hey @thomasin, the changes in your branch look great to me– open a PR and I'll merge it in! |
Problem
Earlier in Discord, a user (shout-out to
bees#5238
) wanted to use Sentry to handle error tracking. To get production error-reporting set up with a CDN link, they need the ability to insert<script>
tags into Elm Land's single HTML file.Unfortunately, the
elm-land.json
configuration file doesn't support that today!Solution
"script": []
field to the defaultelm-land.json
configuration file<script>
tags at the very end of the HTML<head>
tagExample
Let's say I wanted to add the following Sentry CDN script tag to my Elm Land application:
Here's how I would update the
elm-land.json
file:In my browser, I'll see this HTML when I inspect the page source:
The text was updated successfully, but these errors were encountered: