This is a modern, production-ready template for creating Obsidian plugins using Svelte 5 and UnoCSS. It provides a solid foundation with the latest Svelte features, while maintaining compatibility with Obsidian's plugin environment.
$state, $derived).@apply directives, and autoprefixing.i-lucide-search).Use this template:
git clone https://github.com/your-username/your-plugin-name.git
cd your-plugin-name
Install dependencies:
bun install
Start development:
bash bun run dev This will build the plugin and watch for changes, automatically rebuilding when you save a file.
dev script is configured to build the plugin into a test-vault/.obsidian/plugins/your-plugin-name directory. You can open the test-vault in Obsidian to test your plugin.src directory.bun run dev: Start the development server with hot reloading.bun run build: Create a production-ready build of your plugin.bun run check: Run the Svelte compiler to check for errors in your code.bun run format: Format your code using Biome.bun run lint: Lint your code using Biome and apply safe fixes.āāā src
ā āāā components
ā ā āāā ui
ā ā āāā button
ā ā āāā button.svelte
ā ā āāā index.ts
ā āāā lib
ā ā āāā utils.ts
ā āāā views
ā āāā main.ts
āāā biome.json
āāā bun.lock
āāā CHANGELOG.md
āāā components.json
āāā DEVELOPMENT.md
āāā LICENSE
āāā package.json
āāā README.md
āāā tailwind.config.js
āāā Theme.svelte
āāā tsconfig.json
āāā uno.config.ts
āāā vite.config.ts```
* **`src/main.ts`**: The entry point of your Obsidian plugin.
* **`src/components`**: For your Svelte components.
* **`src/components/ui`**: Intended for UI components, especially those from shadcn/ui.
* **`src/lib`**: For utility functions and other library code.
* **`src/views`**: For your Obsidian views.
* **`Theme.svelte`**: A global Svelte component to import CSS resets and UnoCSS styles.
* **`vite.config.ts`**: The configuration file for Vite.
* **`uno.config.ts`**: The configuration file for UnoCSS, where you can customize your styling.
* **`tsconfig.json`**: The TypeScript configuration file.
* **`package.json`**: Defines the project's dependencies and scripts.
* **`biome.json`**: The configuration for the Biome formatter and linter.
* **`components.json`**: The configuration file for shadcn/ui.
## šØ Styling with UnoCSS and shadcn/ui
This template is supercharged with UnoCSS, a highly flexible and fast atomic CSS engine. The configuration is enhanced with several presets and transformers out of the box:
### Presets
* **`presetUno`**: The default, comprehensive utility preset.
* **`presetWind`**: Provides compatibility with Tailwind CSS.
* **`presetAnimations`**: Adds utilities for CSS animations.
* **`presetShadcn`**: A preset for easily integrating with shadcn/ui components.
* **`presetIcons`**: Enables the use of thousands of icons from Iconify. The Lucide icon set is pre-installed (`i-lucide-<icon-name>`).
* **`presetTypography`**: Adds beautiful typographic defaults for prose content.
### Transformers
* **`transformer-variant-group`**: Group utilities with shared variants, like `(hover:&-focus:)(text-red-500 bg-blue-500)`.
* **`transformer-directives`**: Enables the use of `@apply`, `@screen`, and theme functions in your CSS.
### CSS Optimization
* **Autoprefixing**: Automatically adds vendor prefixes to CSS rules for better browser compatibility.
* **Lightning CSS**: Ensures your final CSS is processed and minified with maximum speed.
You can add new shadcn/ui components to your project by running:
```bash
bunx shadcn-svelte@latest add <component-name>
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.