vite-plugin-stachtml
v1.0.2
Published
Stach templating for your vite index.html
Downloads
6
Maintainers
Readme
Vite plugin StachTML
StachTML is a vite plugin to add stach templating into loaded HTML files.
vite.config.js
import { resolve } from "path"
import { stachtml } from "vite-plugin-stachtml"
export default defineConfig( viteConfig => {
return {
build: {
rollupOptions: {
input: [ resolve('src/index.html') ]
},
outDir: resolve('dist'),
},
plugins: {
stachtml({
pageTitle: "Page title",
mainTitle: "Hello from stachTML",
})
}
}
})
src/index.html
<html>
<head>
<title>{{ pageTitle }}</title>
</head>
<body>
<h1>{{ mainTitle }}</h1>
<p>{{ MY_DOT_ENV_VALUE }}</p>
</body>
</html>
.env
Dot envs are also available as template vars. Please check that your env is correctly loaded with vite requirements.
MY_DOT_ENV_VALUE=Value from dot env