Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Handle referenced assets in CSS files #420

Open
Rich-Harris opened this issue Sep 6, 2018 · 1 comment
Open

Handle referenced assets in CSS files #420

Rich-Harris opened this issue Sep 6, 2018 · 1 comment

Comments

@Rich-Harris
Copy link
Member

We're not quite at the point where you can do

import 'typeface-roboto-slab';

inside your app/client.js and have it work, because that import references relative URLs that break when the CSS is extracted.

Those referenced assets presumably need to be copied into the client directory (which I guess should really be called assets, and assets should become static, but we can shave that yak another day), possibly with hashed filenames, and the URLs should be rewritten.

The same presumably goes for @imported files.

This would also allow us to reference relative assets in <style> tags in components.

It's an open question how much of this work belongs to Sapper and how much to Rollup. It feels like bundler territory, but Rollup's ESM-first approach means that it's hard to do in an unopinionated way, which potentially shifts some of the burden back to Sapper.

Also worth considering at the same time: how can CSS transformers (autoprefixers, optimisers, whatever) interact with what Sapper does? And what should we do about @import in <style> tags — should the imported styles be scoped and subjected to DCE? (And if so, how does one dedupe across a bundle?) Lots of tricky inter-related questions, but the payoff is huge if we get the answers right.

@Rich-Harris
Copy link
Member Author

I opened an issue on Rollup to discuss this further: rollup/rollup#2447

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants