Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#279 fixed some stuff but broke AMP CSS, because AMP introduces a tricky requirement.
Ordinarily, we just add
<link rel="stylesheet">
elements, which is easy to do in both dev (because we extract dependencies on the fly as pages are rendered) and prod (because the bundling step produces a manifest). But AMP insists that you inline all the page's CSS in a<style amp-custom>
element, which means we need to get the contents of those files, which is easy enough in dev — just callsnowpack.loadUrl
— but a bit harder in prod because the CSS files might be hosted somewhere else.The solution here is to inline the CSS contents rather than the URLs. (In fact in the AMP case we ideally wouldn't be generating client-side assets at all, but that would involve some larger refactoring than I can get into just now.) I don't love it — it could result in a chunky slow-to-start function, if you weren't careful — but I don't have a great alternative right now, and I need this to work, so...
Anyway. Inlining CSS is a smart thing to do below a certain threshold, so it would be good to come up with a practical solution for this that wasn't limited to AMP documents (and ideally one that didn't involve
fs
given #223).