vite-plugin-nunjucks
vite-plugin-nunjucks copied to clipboard
Processing files other than index.html?
I have a nunjucks template in about/index.njk
and this plugin seems to not process it at all. Or I misunderstood the purpose of this plugin?
You are right. Plugin transforms only .html file. I will add .njk support.
Hey,
importing .njk
files in templates (like: {% extends "src/html/@layout.njk" %}
) works fine. However, the entry point as .njk
is not working due to Rollup and I am not sure why yet. I'm afraid it's more of a Vite/Rollup issue.
If anyone has an idea to make .njk
work as an entry point for Rollup, I'd be happy.
This is quite unfortunate. I've seen that not many (or any) of these template engines work in Vite
without the (main) entry-point(s) as *.html
.
I've tried with Rollup options (rollupOptions
), but no luck there either:
import { resolve } from "path";
import nunjucks from "vite-plugin-nunjucks";
const cwd = process.cwd();
/**
* @type {import("vite").UserConfig}
*/
export default {
build: {
emptyOutDir: true,
manifest: true,
outDir: resolve(cwd, "dist"),
rollupOptions: {
input: {
index: resolve(cwd, "src", "index.njk"),
},
},
sourcemap: true,
},
plugins: [nunjucks()],
root: resolve(cwd, "src"),
};
What is the status of this ? im using storybook and vite and tried this to add support for njk file imports but as its only working with index.html files im a bit stumbled to how to solve this is it even possible ?
Any help on this would be appreciated by someone who is in touch with new versions of Vite.