{"id":13774908,"url":"https://github.com/juliendargelos/rollup-plugin-emit-ejs","last_synced_at":"2025-07-18T09:36:30.072Z","repository":{"id":35111661,"uuid":"208084204","full_name":"juliendargelos/rollup-plugin-emit-ejs","owner":"juliendargelos","description":"Emit files from ejs with rollup","archived":false,"fork":false,"pushed_at":"2023-01-06T07:03:01.000Z","size":1786,"stargazers_count":4,"open_issues_count":16,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T07:41:18.951Z","etag":null,"topics":["ejs","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliendargelos.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-12T15:31:38.000Z","updated_at":"2025-01-25T07:51:18.000Z","dependencies_parsed_at":"2023-01-15T14:03:41.030Z","dependency_job_id":null,"html_url":"https://github.com/juliendargelos/rollup-plugin-emit-ejs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/juliendargelos/rollup-plugin-emit-ejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliendargelos%2Frollup-plugin-emit-ejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliendargelos%2Frollup-plugin-emit-ejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliendargelos%2Frollup-plugin-emit-ejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliendargelos%2Frollup-plugin-emit-ejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliendargelos","download_url":"https://codeload.github.com/juliendargelos/rollup-plugin-emit-ejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliendargelos%2Frollup-plugin-emit-ejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265735353,"owners_count":23819710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ejs","rollup","rollup-plugin"],"created_at":"2024-08-03T17:01:31.640Z","updated_at":"2025-07-18T09:36:30.042Z","avatar_url":"https://github.com/juliendargelos.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Output"],"readme":"# rollup-plugin-emit-ejs\n\n[![test](https://github.com/juliendargelos/rollup-plugin-emit-ejs/workflows/test/badge.svg?branch=master)](https://github.com/juliendargelos/rollup-plugin-emit-ejs/actions?workflow=test)\n[![build](https://github.com/juliendargelos/rollup-plugin-emit-ejs/workflows/build/badge.svg?branch=master)](https://github.com/juliendargelos/rollup-plugin-emit-ejs/actions?workflow=build)\n[![version](https://img.shields.io/github/package-json/v/juliendargelos/rollup-plugin-emit-ejs)](https://github.com/juliendargelos/rollup-plugin-emit-ejs)\n\nThis plugin allows you to emit files from ejs templates to rollup bundle.\n\nIt is primarily meant to emit html files since it helps you to link bundled javascripts/stylesheets and includes a basic layout system, but it can deal with any file type.\n\nUnlike [rollup-plugin-bundle-html](https://github.com/haifeng2013/rollup-plugin-bundle-html), this plugin uses the [emitFile()](https://rollupjs.org/guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string) plugin context method which allow other plugins like [rollup-plugin-html-minifier](https://github.com/juliendargelos/rollup-plugin-html-minifier) to process the emitted files.\n\n## Install\n\n```bash\nyarn add rollup-plugin-emit-ejs --dev\n```\n\nor\n\n```bash\nnpm install rollup-plugin-emit-ejs -D\n```\n\n## Usage\n\n```javascript\n// rollup.config.js\n\nimport emitEJS from 'rollup-plugin-emit-ejs'\n\nexport default {\n  // ...\n  plugins: [\n    emitEJS({\n      src: 'src',\n      layout: 'src/layout.html.ejs',\n      data: {\n        title: 'Hey',\n        body: 'Hey Hey Hey'\n      }\n    })\n  ]\n}\n```\n\n```ejs\n\u003c!-- src/layout.html.ejs !--\u003e\n\n\u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003e\u003c%= title %\u003e\u003c/title\u003e\n    \u003c% stylesheets.forEach(stylesheet =\u003e { %\u003e\n      \u003clink rel=\"stylesheet\" href=\"\u003c%= stylesheet %\u003e\"\u003e\n    \u003c% }) %\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003c%- content %\u003e\n    \u003c% javascripts.forEach(javascript =\u003e { %\u003e\n      \u003cscript src=\"\u003c%= javascript %\u003e\"\u003e\u003c/script\u003e\n    \u003c% }) %\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n```ejs\n\u003c!-- src/index.html.ejs !--\u003e\n\n\u003cmain\u003e\n  \u003cp\u003e\u003c%= body %\u003e\u003c/p\u003e\n\u003c/main\u003e\n```\n\nThis will emit a file named `index.html` next to the javascript bundle file.\n\n## Options\n\n```typescript\n{\n  src: string\n  dest?: string\n  include?: string | string[]\n  exclude?: string | string[]\n  layout?: string\n  extension?: string\n  data?: Data\n  options?: Options\n}\n```\n\n### src\n\nSource directory to find ejs templates from.\n\nRequired\n\n### dest\n\nRelative path from bundle location where to output files from ejs templates.\n\nDefault: `'.'`\n\n### include\n\nGlob or array of globs defining which templates to include.\n\nDefault: `'**/*.ejs'`\n  \n### exclude\n\nGlob or array of globs defining which templates to exclude.\n\nDefault: `[]`\n\n\u003e Note that the template provided in the `layout` option is automatically excluded.\n\n### layout\n\nPath to an ejs template to use as layout. Skip this option if you don't need layout.\n\nDefault: `undefined`\n\n### extension\n\nExtension to append to emitted files (the leading `.` can be omitted).\n\nDefault: `undefined`\n\n\u003e Note that the trailing `.ejs` extension is automatically removed from template filenames. So this option is useful if you only want to use the `.ejs` extension in your template filenames, but need to replace it with another extension like `.html`. Otherwise, you can just stack the output extension directly in the filename (`index.html.ejs`) and skip this option.\n\n### data\n\nData to pass to ejs.\n\nDefault: `{}`\n\n\u003e The following helper variables are forced by the plugin and available in all templates:\n\u003e - `javascripts`: array of relative paths to javascripts\n\u003e - `stylesheets`: array of relative paths to stylesheets\n\u003e\n\u003e In the layout, an extra `content` variable is passed containing the content to wrap into the layout. This variable needs to be printed **unescaped** if you want to use it as html, use the corresponding ejs tag: `\u003c%-` (See [ejs tags](https://github.com/mde/ejs#tags))\n\n### options\n\nOptions to pass to ejs. (See [ejs options](https://github.com/mde/ejs#options))\n\nDefault: `{}`\n\n\u003e Note that the `filename` options is forced by the plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliendargelos%2Frollup-plugin-emit-ejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliendargelos%2Frollup-plugin-emit-ejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliendargelos%2Frollup-plugin-emit-ejs/lists"}