0.1.3 • Published 10 months ago
vite-plugin-write-pages v0.1.3
vite-plugin-write-pages
Description
Vite plugin for writing generated html strings to .html
files.
Installation
npm
$ npm i vite-plugin-write-pages -D
yarn
$ yarn add vite-plugin-write-pages -D
Usage
./path/to/the/page/generator.js
/* Generating html pages as html strings. */
export default [
{ path: './index.html', content: 'generated html string' },
{ path: './other/dir/example.html', content: 'generated html string' },
]
./vite.config.js
import { defineConfig } from 'vite'
import { resolve } from 'node:path'
import { vitePluginWritePages } from 'vite-plugin-write-pages'
import appPages from './path/to/the/page/generator.js'
const vitePages = {}
appPages.forEach((appPage, i) => {
vitePages[i] = resolve(__dirname, appPage.path)
})
export default defineConfig({
build: {
rollupOptions: { input: vitePages },
// other options...
},
plugins: [
vitePluginWritePages(appPages),
],
})