SvelteKit and Sass setup?
Hi! I am setting up a new project that uses Sass in SvelteKit, and I am trying to find examples of config setup and file organization. I've only used Sass with vanilla JavaScript, TypeScript and React projects, nothing full-stack. If anybody knows of any helpful walkthroughs or projects I could look through on GitHub I would love that advice. There's so many plugins and config files I'm worried I'll get stuck and not be able to debug otherwise. Thanks!
49 Replies
So because SvelteKit is just a Vite plugin you can its pretty simple. Vite already supports Sass out the box and you just use its preprocessor for svelte.
svelte.config.js
so now you can import sass files into your layout lets say.
oh don't forget to install
pnpm i -D sass
to your project if you have not eitherok I think I am starting to understand, there's also a
vite.config.js
file to setup too?
(this is extremely helpful, thank you)Yea you should have two configs one for svelte one for vite.
(and then a postcss.config.js, I'm sometimes not sure where to put configuration based on docs)
ok good then I'm not too far off in the weeds
yup! if you use postcss plugins
which you should lots of good postcss plugins depending on your needs.
yes I really want to, just setting expectations ๐
Vite is all setup to use it though so you just edit that config.
SvelteKit you will see in the vite.config is just a plugin ๐ so if you want to use other vite plugins it should work pretty well.
ok thank you, I think I've mixed these two files contents' a bit but this will help me sort it out
long as its not like framework specific.
Its nice separation honestly, it was not like that during beta. Just think each one has a config aptly named.
Which is how it should be ๐
would it be okay if I posted my cofigs here once I've fixed them?
Sidenote: if you use vsCode it has a nice way to combine like files. I just have all my configs/rc files collapsed into one.
same with ignore and package xD
oh is it an extension?
thanks
(I'm just taking a lot of screenshots because my brain is pudding at this point)
vite.config.js
that is old
I mean you can still use Svelte preprocessor but its old
and no longer maintained by the team I'm pretty sure. The default is now to use Vites straight out.
(sorry trying to figure out how to make it look like JavaScript)
ok, I'll just use the vite plugins
```js
did you do a fresh install?
cause that is some old config options there.
nothing since we've started chatting
ah following a guide?
I was trying to follow docs, but clearly the wrong one
yea which
that is what I'm trying to learn so we can get it fixed xD
for the docs or this project? I think I manually entered a lot of that, but I'll look through my browser history because I've been on too many to remember which one at this point
might have been this: https://github.com/sveltejs/svelte-preprocess/blob/main/docs/preprocessing.md#auto-preprocessing
GitHub
svelte-preprocess/docs/preprocessing.md at main ยท sveltejs/svelte-p...
A โจ magical โจ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more. - sveltejs/svelte-preprocess
But the way you explained it makes sense, to just use the Vite plugins since SvelteKit is running on Vite
*is a Vite plugin I mean
yea they made that switch during beta.
Which was smart choice cause now its abstracted away and you don't need some special svelte way.
hence they switched to Vite preprocessor by default now ๐
I love Vite so much, glad it's getting adopted everywhere
I see you did Kevin's BeyondCSS course, I'm essentially trying to port my Sass starter template into a SvelteKit project
Oh nice!
so some of my setup is from that, if it adds context
Yea I beta tested it but have to be honest I have not taken it really ๐ฆ
Def going to do the last model though ๐
Also I made the converter used in the course >.>;;
in SvelteKit
oohhhh really?
yup!
that sounds like a lot of work
At the time sass only had the node compiler so it was perfect for it
I did not care about sass before that course, but now I'm invested because of the token maps
heheheh
thanks for helping me with this
are you on GitHub?
same handle yea
I'm
b1mind
everywhereI will peek at your converter
oh that wont be public I don't keep any client work public and well Kevin was a client lol
its his code now
ohhh no worries
well it's nice to get work like that
Also it was early beta things are done pretty different. It wouldn't help much into SvelteKit but I have other stuff up that is public that might feel free.
I'm working with Prismic right now and enjoying it some in my free time.
Looking forward to seeing how well TinaCMS and Kit do in Kevins last model though.
I will def be taking that part of the course. Then might go back into it for me to see how he does design systems in sass.
I keep forgetting there's going to be more, i'm excited for that
me too! Congrats on completing it btw ๐ช
Was a big course ๐ฎ
thanks! that's what gives me the dopamine, finishing the course
hell yea love that high
I'm kinda on one right now learning Prismic CMS hehe
I'll have to look that up
Need to get back into it
They just recently launched some decent Kit support only to get better so.
their UI is really cute
homepage I mean
@b1mind just looking at some of your stuff on Github and it's answered a lot of minor questions I had (like file organization, where to put locally hosted fonts) ๐ It's my first time setting up a svelte project, and sometimes "reading" somebody else's project gives better context than following tutorials.
Sorry shouldn't have done the @
its fine glad that helps!