unplugin-eta3
v1.0.2
Published
Plugin to precompile Eta functions, making it possible to be used in serverless context like Cloudflare Workers
Downloads
6
Maintainers
Readme
unplugin-eta3
Plugin to precompile Eta functions, making it possible to be used in serverless context like Cloudflare Workers.
Install
npm i --save-dev unplugin-eta3
// vite.config.ts
import eta from "unplugin-eta3/vite";
export default defineConfig({
plugins: [
eta({ /* options */ }),
],
});
Example: playground/
// rollup.config.js
import eta from "unplugin-eta3/rollup";
export default {
plugins: [
eta({ /* options */ }),
],
};
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-eta3/webpack")({ /* options */ })
]
};
// nuxt.config.js
export default defineNuxtConfig({
modules: [
["unplugin-eta3/nuxt", { /* options */ }],
],
});
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require("unplugin-eta3/webpack")({ /* options */ }),
],
},
};
// esbuild.config.js
import { build } from "esbuild";
import eta from "unplugin-eta3/esbuild";
build({
plugins: [eta()],
});
TypeScript Types
Declare the module
declare module "*.eta" {
import type { TemplateFunction } from "eta/dist/types/compile";
const template: TemplateFunction;
export default template;
}
Usage
Hello <%= it.hello %>!
import { Eta } from "eta";
import template from "./template.eta";
const eta = new Eta();
const output = eta.render(template, { hello: "World" });
console.log(output);