@nakshora/vite-plugin
v3.1.0
Published
Nakshora plugin for Vite — virtual CSS module, PostCSS at-rules and HMR
Maintainers
Readme
@nakshora/vite-plugin
The smoothest Nakshora experience — import 'nakshora' as a virtual CSS
module, @nakshora … at-rules inside your .css files, and HMR when your
markup changes.
Nakshora is a utility-first CSS framework with a JIT compiler and a Tailwind-compatible class grammar: 11,417 utilities, state + responsive variants, design components and theme presets, compiled down to only the classes you use.
Install
npm install -D @nakshora/vite-pluginvite ^5 || ^6 || ^7 || ^8 is a peer dependency (each major is exercised by a real vite build in test/integration.test.ts; Vite 7+ needs Node ≥ 20.19).
Quick start
// vite.config.js
import { defineConfig } from 'vite';
import { nakshora } from '@nakshora/vite-plugin';
export default defineConfig({
plugins: [
nakshora({
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx,vue}'],
}),
],
});// src/main.js
import 'nakshora'; // ← all of Nakshora, compiled for your contentnpm run devChange a class in your markup → the virtual module is invalidated → HMR refresh.
Options
nakshora({
config: {/* NakshoraConfig: theme, safelist, important, darkMode, plugins… */},
content: ['./src/**/*.html'], // JIT globs relative to the project root (overrides config.content)
minify: false, // Vite minifies in production anyway
postcss: true, // also process @nakshora at-rules inside .css files
});How it works
- Virtual module —
import 'nakshora'(orimport 'virtual:nakshora') resolves to a generated CSS module:contentconfigured → JIT compile of exactly the classes you use- no content → full build
- PostCSS pipeline — the plugin injects
@nakshora/postcss into
Vite's CSS processing, so real
.cssfiles can use@nakshora source;and friends. - HMR — content paths are watched; on change the virtual module is invalidated and the browser updates without a full reload.
CSS-file style
Prefer a classic entry file over the virtual module?
/* src/nakshora.css */
@nakshora source;import './nakshora.css';Documentation
License
MIT © Rizwan Rahim Chowdhury — nakshora/nakshora
