{"id":14982438,"url":"https://github.com/trapcodeio/vite-plugin-ejs","last_synced_at":"2025-09-09T16:43:49.463Z","repository":{"id":50763615,"uuid":"356087922","full_name":"trapcodeio/vite-plugin-ejs","owner":"trapcodeio","description":"Vite: Use Ejs in your entypoints i.e index.html","archived":false,"fork":false,"pushed_at":"2023-11-16T20:56:27.000Z","size":81,"stargazers_count":67,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-19T15:56:31.905Z","etag":null,"topics":["ejs","vite"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/vite-plugin-ejs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trapcodeio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-09T00:41:28.000Z","updated_at":"2025-03-28T09:07:16.000Z","dependencies_parsed_at":"2024-06-18T15:27:41.560Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/vite-plugin-ejs","commit_stats":{"total_commits":47,"total_committers":5,"mean_commits":9.4,"dds":0.1063829787234043,"last_synced_commit":"b752661e49ba447791284ff5221c40a16ac2545a"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/trapcodeio/vite-plugin-ejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fvite-plugin-ejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fvite-plugin-ejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fvite-plugin-ejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fvite-plugin-ejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/vite-plugin-ejs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fvite-plugin-ejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261126708,"owners_count":23113332,"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","vite"],"created_at":"2024-09-24T14:05:24.852Z","updated_at":"2025-06-25T13:38:04.343Z","avatar_url":"https://github.com/trapcodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-ejs\n\nUse [ejs](https://www.npmjs.com/package/ejs) template language in your entrypoint i.e `index.html`\n\n**Note:** For Vite version \u003c `5` use [`v1.6.4`](https://www.npmjs.com/package/vite-plugin-ejs/v/1.6.4) of this plugin.\n\n## Menu\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Default Data](#default-data)\n    - [Configure EJS](#configure-ejs)\n\n### Installation\n\n```sh\nnpm i vite-plugin-ejs\n# or\nyarn add vite-plugin-ejs\n```\n\n### Usage\n\nFile: **vite.config.js**\n\n```javascript\nimport {defineConfig} from \"vite\";\nimport {ViteEjsPlugin} from \"vite-plugin-ejs\";\n\nexport default defineConfig({\n  plugins: [\n    // Without Data\n    ViteEjsPlugin(),\n    \n    // With Data\n    ViteEjsPlugin({\n      domain: \"example.com\",\n      title: \"My vue project!\"\n    }),\n    \n    // Or With Vite Config\n    ViteEjsPlugin((viteConfig) =\u003e {\n      // viteConfig is the current viteResolved config.\n      return {\n        root: viteConfig.root,\n        domain: \"example.com\",\n        title: \"My vue project!\"\n      }\n    }),\n  ],\n});\n```\n\nFile: **index.html**\n\n```ejs\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"/\u003e\n    \u003clink rel=\"icon\" href=\"/favicon.ico\"/\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/\u003e\n    \u003ctitle\u003e\u003c%= domain %\u003e | \u003c%= title %\u003e\u003c/title\u003e\n\n    \u003c!-- Run Conditions--\u003e\n    \u003c% if(isDev){ %\u003e\n        \u003cscript src=\"/path/to/development-only-script.js\"\u003e\u003c/script\u003e\n    \u003c% } else { %\u003e\n        \u003cscript src=\"/path/to/production-only-script.js\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n    \u003c% } %\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=\"app\"\u003e\u003c/div\u003e\n\u003cscript type=\"module\" src=\"/src/main.ts\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nNote: `isDev` is included in your data by default\n\n### Default Data\n\nThe object below is the default data of the render function.\n\n```javascript\nreturn {\n  NODE_ENV: config.mode,\n  isDev: config.mode === \"development\"\n}\n```\n\n### Configure EJS\n\nYou can configure ejs by passing an object to the plugin.\n\n```js   \nexport default defineConfig({\n  plugins: [\n    ViteEjsPlugin(\n        {title: 'My vue project!'},\n        {\n          ejs: {\n            // ejs options goes here.\n            beautify: true,\n          },\n        }\n    ),\n  ],\n});\n```\n\nIf you want to use `viteconfig` to configure ejs, you can pass a function to the plugin, the function will receive the\ncurrent vite config as the first argument.\n\n```js\nexport default defineConfig({\n  plugins: [\n    ViteEjsPlugin(\n        {title: 'My vue project!'},\n        {\n          ejs: (viteConfig) =\u003e ({\n            // ejs options goes here.\n            views: [viteConfig.publicDir]\n          })\n        }\n    ),\n  ],\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fvite-plugin-ejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fvite-plugin-ejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fvite-plugin-ejs/lists"}