@reactive-contracts/vite-plugin
v0.2.0
Published
Vite plugin for Reactive Contracts - auto-compile contracts with HMR support
Maintainers
Readme
@reactive-contracts/vite-plugin
Vite plugin for Reactive Contracts - automatically compile contracts during development with HMR support.
Features
- 🔄 Auto-compile - Contracts are automatically compiled when files change
- ⚡ HMR Support - Hot Module Replacement for contract changes
- 🛠️ Dev Mode Warnings - Clear console warnings and error messages
- 📦 Zero Configuration - Works out of the box with
rcontracts.config.ts
Installation
# npm
npm install @reactive-contracts/vite-plugin -D
# pnpm
pnpm add @reactive-contracts/vite-plugin -D
# yarn
yarn add @reactive-contracts/vite-plugin -DUsage
Add the plugin to your vite.config.ts:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactiveContracts } from '@reactive-contracts/vite-plugin';
export default defineConfig({
plugins: [
react(),
reactiveContracts(),
],
});Configuration
The plugin uses your existing rcontracts.config.ts file by default. You can also pass options directly:
reactiveContracts({
// Path to config file (default: './rcontracts.config.ts')
configFile: './rcontracts.config.ts',
// Enable/disable HMR (default: true)
hmr: true,
// Compile on build start (default: true)
compileOnBuildStart: true,
// Log level: 'verbose' | 'normal' | 'silent' (default: 'normal')
logLevel: 'normal',
})How It Works
- Build Start: Compiles all contracts when Vite starts
- File Watch: Watches
contracts/**/*.contract.tsfor changes - HMR: When a contract changes, it recompiles and triggers HMR for affected modules
- Error Reporting: Shows clear errors in the Vite console
Requirements
- Vite 5.0+
- A valid
rcontracts.config.tsconfiguration file - Contract files matching the configured glob pattern
License
MIT
