Best Products
Launches
Launch archive
Most-loved launches by the community
Launch Guide
Checklists and pro tips for launching
News
Newsletter
The best of Product Hunt, every day
Stories
Tech news, interviews, and tips from makers
Changelog
New Product Hunt features and releases
Forums
Forums
Ask questions, find support, and connect
Kitty Points Leaderboard
The highest scoring community members
Streaks
The most active community members
Events
Meet others online and in-person
Advertise
Subscribe
Sign in
Clear text
recent
p/self-promotion
by
Andrew Gabaraev
•
1mo ago
I built a Vite plugin that saves CSS changes directly to your source files
... filePath, root.toString()); // formatting preserved For SCSS, postcss-scss is used it understands SCSS syntax including $variables, nesting, and mixins that standard PostCSS doesn't parse. HMR: from setTimeout to confirmation The first version looked like this: after sending the
patch
over WebSocket, wait 400ms, then re-read the CSSOM. send({ fileUrl, selector, prop, value }); setTimeout(() => { editor.refresh(); }, 400); // fixed wait The problem: after writing the file, Vite goes through several steps the file watcher detects the change, Vite recompiles ... ... slow machines 400ms wasn't enough. On fast ones wasted time. The fix: the server sends a confirmation only after writing the file. The client waits for this signal, not a timer. // server after writeFileSync: socket.send(JSON.stringify({ type: "
patched
0
1
Subscribe
Sign in