Vite Integration #277
Replies: 4 comments 10 replies
-
I think an html template would be the most straightforward way to manage entrypoints and other global configuration like 3rd party scripts/fonts. On the other hand, this approach may lead users to skip the awesome Head elm module and put everything in the html template. Even worse, they might put something in the body and end up confused since elm would remove it. |
Beta Was this translation helpful? Give feedback.
-
speaking of the Head module, perhaps it would be enough to allow users to define their entrypoints using that? for example |
Beta Was this translation helpful? Give feedback.
-
Users might want to specify their entrypoints in a particular order, e.g. load the minimal css (or even inline it) before the full stylesheet, or load some script before the elm app because it's needed for init flags |
Beta Was this translation helpful? Give feedback.
-
I think that to let the user do import "style.css" is a good idea in the index.ts or index.js. The way I do it now is with a script in package.json with concurrently. I feel that having Vite and no taking advantage of its capabilities is a waste. I don't know if it causes extra network waterfall chain - I really don't get what you mean with this. Not sure, just a point of view. Regards. |
Beta Was this translation helpful? Give feedback.
-
What and Why
I've previously talked about my goal to have
elm-pages
be lean and unopinionated regarding building and bundling non-Elm assets: #148.elm-pages
used to be built on Webpack, and I didn't want to expose any webpack internals because:elm-pages
to Webpack, andSo the goal was to be opinionated about how to build and optimize an Elm application (to consider that a core responsibility of
elm-pages
), and then let the user deal with bundling and optimizing the rest of their assets.I think this is the right overall direction, but Vite has changed things in a couple of important ways:
elm-pages
can use as a framework (other frameworks like SvelteKit and Astro are building around that feature as well)I've got a Vite integration working smoothly. I'm really pleased with how snappy it is and how convenient it is to get that nice bundling for production and fast dev server handling for non-Elm resources.
I just need to clean up a few things and then I'll push that up. But there are a few design decisions that come up with this new integration.
New Questions for the Vite Integration
index.js
andstyle.css
? What if you wantindex.ts
orstyle.scss
?)?import "style.css"
, but does that cause problems for an extra network waterfall chain? What about<link>
preload directives, should those be automated, or not?This is also related to #195.
I would love to hear people's thoughts on this. This will open up some design decisions that will need to be explored, so I'd love to hear people's ideas and use cases around this.
Beta Was this translation helpful? Give feedback.
All reactions