Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Handling CSS with webpack #59

Open
maxmilton opened this issue May 8, 2018 · 3 comments
Open

Handling CSS with webpack #59

maxmilton opened this issue May 8, 2018 · 3 comments

Comments

@maxmilton
Copy link

Currently CSS processing is rather rudimentary; static global CSS in the assets dir and svelte component CSS included in JS bundles. That's all well and good for a demo or PoC but the reality is production sites need more flexibility, repeatability, and automation.

Since we're using webpack for bundling, it should also be set up to handle generating CSS file/s. A link to the file/s should also be injected into the page template.

Using css-loader + style-loader/mini-css-extract-plugin is probably all we need for most projects to get started. This is easy to set up but now we also need to add a <link rel=stylesheet> to the head which doesn't automatically happen. In other webpack projects I would use html-webpack-plugin but that seems like overkill when sapper is already handling template.html.

So, what we need for this is:

  1. Change webpack client config: sevelte to pass CSS to webpack + handle CSS via webpack loaders.
  2. Provide a way to inject CSS file/s via a <link>.

For reference, here's what I'm using in one of my new projects, which covers 1. It also uses postcss but that's not necessary for sapper-template.

@ratson
Copy link
Contributor

ratson commented May 14, 2018

I am trying out sapper, immediate findglobal.css is static and not minified after build. A workaround would be having separate build step for it, but is there a more elegant way?

@gavinmcfarland
Copy link

gavinmcfarland commented Sep 22, 2018

Experienced similar situation when I was importing variables into global.css. For ease I ended up creating a wrapper component and putting all the contents of global.css into it which all other components are used inside of.

@LockeAG
Copy link

LockeAG commented May 22, 2019

yep, I'm working in some combination like with https://github.com/DreamsEngine/base-engine-ts or https://github.com/bstaruk/starbase , but I haven't had much time, I will try maybe next week

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

No branches or pull requests

4 participants