An Rsbuild plugin to provide support for the EJS template engine.
Install:
npm add rsbuild-plugin-ejs -DAdd plugin to your rsbuild.config.ts:
// rsbuild.config.ts
import { pluginEjs } from "rsbuild-plugin-ejs";
export default {
plugins: [pluginEjs()],
};After the plugin registration is completed, Rsbuild will automatically parse template files with the .ejs extension and compile them using the EJS template engine.
For example, first create a src/index.ejs file, and point to that file using html.template:
export default {
html: {
template: "./src/index.ejs",
},
};Then, you can use EJS syntax in the index.ejs template:
<!-- Input -->
Hello <%= foo %>!
<!-- Output -->
Hello Rsbuild!Refer to the EJS documentation for more details.
Used to set the compilation options for EJS. For detailed options, please refer to the EJS API Reference.
- Type:
import('ejs').Options - Default:
const defaultOptions = {
filename,
};- Example:
pluginEjs({
ejsOptions: {
delimiter: "|",
},
});MIT.