UnoCSS Starter Theme - Reload UnoCSS config

Changes in uno.config.js will not be reloaded automatically.

You can trigger it manually by restarting the vite server.

Type "r" and then "enter" when the dev server is running.

It should say:

5:09:22 PM [vite] server restarted.

This is done in the terminal, but you make changes in your IDE, and would rather switch back to your browser.

To automatically restart the server, import the uno config file into the vite config and pass it into the UnoCSS plugin.

import UnoCSS from "unocss/vite";
import unoConfig from "./uno.config.js";
import { defineConfig } from "vite";

export default defineConfig({
 plugins: [
   UnoCSS(unoConfig)
 ],

Now changes in the config file should automatically reload the page.

Tags