-
-
Notifications
You must be signed in to change notification settings - Fork 432
Feature request: global and component local Sass (or similar) #357
Comments
+1 for an integrated global CSS generation from preprocessor files |
This also relates somewhat to: sveltejs/svelte#1808 with the notion of an "unscoped" style tag. |
Svelte already has an option to proprocess styles which covers components and rollup/webpack can handle preprocessing global styles. Additionally, sapper has no way of passing in any global build configuration options other than your rollup/webpack config. What are you proposing? Maybe we just need better documentation with examples of how to set up the most common style preprocessors? |
What would be great is a having a shared preprocessing for both global and local style. |
@wighawag I just import my variables file into my components. |
Each component's preprocessors are run in a separate context so it's not like there's one "local style scope", there's actually many. It's powerful to have that level of encapsulation per component. I do exactly the same thing as @antony , I use a magic |
I tried to do the same as @antony mentioned. Just import styles in each component. It kinda works but then console lists lots of warnings about unused scss selectors. (I'm trying to use roolup + scss preprocessing) Easy way to config global scss would a be nice feature. |
This is a blocker for me.... |
@ccinelli Can you explain why it is a blocker? There are solutions for component global SASS and also for site wide SASS. |
@antony Could you please elaborate how can we set global SASS variables and mixins? Is importing in every component the only solution? |
This can't really be 'blocking', the Global CSS file is right there and you can do anything you want with it. If you need those SASS (or similar) variables inside component style tags then they can be imported and used providing you are using the relevant style preprocessor. What probably is missing is some way to include extra files in your rollup or webpack config (or something to that effect), right now the bundler configs are handled in a way that is very specific to sapper and any processing of other files has to be handled separately. I think it may be possible to improve this situation. However, the chance of Sapper getting first class support for SASS, Stylus, LESS, etc. is approximately zero. |
@pngwn Could you explain, why zero? And how you measure this probability? Short documented instructions how to add sass, stylus, less, etc into the build would be enough. |
Because it is not the job of Svelte or Sapper to have opinions about how you should handle your CSS. Svelte's We are currently in the process of writing more documentation explaining how to preprocess your components (amongst other things), so this should be available within a reasonable timeframe. Converting a plain file from SASS etc. into plain CSS can be done with a simple script, there are plenty of tutorials explaining this process. Although, as I said, providing a more elegant way to do this in Sapper might be possible. |
There are existing ways to have compile-to-CSS languages in your components - via preprocessors. As mentioned, we can do a better job documenting these, and writing a sort of cookbook of typical pieces you can put together will help. But there's nothing we want to do in Sapper or Svelte to have 'first class support' for these. Preprocessors are the support. Using a compile-to-CSS language in your global styles is even simpler. As mentioned, you can just write a script to compile your files into global.css, and put this in the npm scripts before Sapper is run. The building blocks for this already exist. There's no need to write, maintain, and document hooks for Sapper to run scripts before it performs the compilation when there is an existing extremely well-known way of doing this already - using |
I like the idea on not having a lot of opinions but what I would like more is Sapper being more popular than nuxt/next/gatsby, to achieve that, opinions work for ease of development and popularity among less experienced users. |
So far, it is straightforward to follow advice in issues or discussion (#123), to add support for component level styles; and this is supported by the VSCode plug-in. But this doesn't provide global Sass support (that is, for the global CSS), and of course must be wired separately (including a build process "around" Sapper for global styles) by each application.
This is a feature request to have either Sass, or more ideally a selection of the common CSS processing tools, available "off the shelf in the box" with Sapper.
I believe this feature is in the spirit of Supper, as it would execute entirely at compile time, and (perhaps with some optimization add-on) continue the Sapper/Svelte goal of doing work at compile time to bridge between concise, fluent application code and small, fast runtime code.
The text was updated successfully, but these errors were encountered: