1.1.1 ⢠Published 5 months ago
@povly/vite-plugin-pug v1.1.1
Vite Plugin for Pug to HTML Conversion
This plugin for Vite allows you to convert Pug files to HTML. It tracks changes in the folder src/pug/ and converts files from src/pug/pages to `dist'.
Installation
Install the plugin using npm or yarn:
npm i @povly/vite-plugin-pug -DConfiguration
Create a vite.config.js configuration file and import the plugin:
// vite.config.(js|ts)
import { defineConfig } from "vite"
import PugConverter from "@povly/vite-plugin-pug"
const config = {
  paths: {
    src: 'src/pug',
    pages: 'src/pug/pages',
    output: 'dist'
  },
  renderOptions: {
    pretty: true,
    cache: false
  },
  serverOptions: {
    close: true,
    watcher: true
  }
};
export default defineConfig({
  plugins: [PugConverter(config)],
})Plugin Parameters - Config
| Name | Type | Description | 
|---|---|---|
paths | object | Optional. Path configurations for source, pages, and output directories. | 
paths.src | string | Path to the source Pug files for tracking. Default: src/pug | 
paths.pages | string | Path to the Pug pages for conversion. Default: src/pug/pages | 
paths.output | string | Path for the output HTML files. Default: dist/html | 
renderOptions | object | Optional. Rendering options for Pug. Default: pretty:true and cache:false | 
serverOptions | object | Optional. Server options. | 
serverOptions.close | boolean | Disconnects tracking after the server closing. Default: true | 
serverOptions.watcher | boolean | Enable watching for changes. Default: true | 
š Example of a structure
project/
āāā src/
ā āāā pug/
ā  āāā pages/ # Main pages
ā  ā āāā index.pug
ā  ā āāā about.pug
ā  āāā includes/ # Plug-in components
ā  ā āāā head.pug
ā  ā āāā footer.pug
|  āāā etc.
āāā dist/
  āāā index.html
  āāā about.htmlš Features
- Hot Reload: Automatic reassembly when files are changed in src/pug/
 - Flexible paths: Customization of input/output directories
 - Pug settings: Full control over rendering options
 - Integration with Vite: Works with dev server and production build
 
Contribution
Thank you for contributing in the project. If something is simply not working, please raise an issue. PRs certainly welcome! (.ā į“ ā.)
Additional Information
I use a layout build without a framework from this link: Vite Template HTML