DEV Community

Qichao
Qichao

Posted on • Edited on

2 2

Vite.js, Sevelte.js, and Windi CSS: The Perfect Combo for My Web Dev

Why

Vite is fast.

Svelte is elegant.

Windi CSS is easier to install than Tailwind on Vite-Svelte.
And you should read this before you choose: https://github.com/windicss/windicss/discussions/176

Preparation

I strongly recommend pnpm as it is much faster and saves spaces on disks. If you haven't installed it, run:

npm i -g pnpm
Enter fullscreen mode Exit fullscreen mode

Get started

First, create new vite project using:

pnpm create vite
Enter fullscreen mode Exit fullscreen mode

Then choose svelte in the interactive CLI dialog.

Then:

cd projectFolder
pnpm i
pnpm i -D vite-plugin-windicss windicss
Enter fullscreen mode Exit fullscreen mode

Then in vite.config.js:

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import WindiCSS from 'vite-plugin-windicss'

// https://vitejs.dev/config/
export default {
  plugins: [
    WindiCSS(),
    svelte()
  ],
}
Enter fullscreen mode Exit fullscreen mode

In main.js:

import 'virtual:windi.css'
Enter fullscreen mode Exit fullscreen mode

Done!

pnpm dev
pnpm build
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay