{"id":11989353,"url":"https://github.com/rspack-contrib/rsbuild-plugin-pug","last_synced_at":"2025-04-14T10:13:47.015Z","repository":{"id":246782801,"uuid":"822451776","full_name":"rspack-contrib/rsbuild-plugin-pug","owner":"rspack-contrib","description":"An Rsbuild plugin to provide support for the Pug template engine.","archived":false,"fork":false,"pushed_at":"2025-04-01T02:29:55.000Z","size":162,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T10:13:40.382Z","etag":null,"topics":["rsbuild","rsbuild-plugin","rspack"],"latest_commit_sha":null,"homepage":"","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/rspack-contrib.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-01T07:20:29.000Z","updated_at":"2025-04-01T02:29:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb32b1eb-c2e4-44de-8e78-1b01638a5b81","html_url":"https://github.com/rspack-contrib/rsbuild-plugin-pug","commit_stats":null,"previous_names":["rspack-contrib/rsbuild-plugin-pug"],"tags_count":2,"template":false,"template_full_name":"rspack-contrib/rsbuild-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-pug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-pug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-pug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-pug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rsbuild-plugin-pug/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860167,"owners_count":21173342,"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":["rsbuild","rsbuild-plugin","rspack"],"created_at":"2024-07-02T13:09:48.757Z","updated_at":"2025-04-14T10:13:46.992Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"readme":"# @rsbuild/plugin-pug\n\nAn Rsbuild plugin to provide support for the Pug template engine.\n\n\u003e [Pug](https://github.com/pugjs/pug) is a robust, elegant, feature rich template engine for Node.js.\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/@rsbuild/plugin-pug\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/@rsbuild/plugin-pug?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n\u003c/p\u003e\n\n## Usage\n\nInstall:\n\n```bash\nnpm add @rsbuild/plugin-pug -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginPug } from \"@rsbuild/plugin-pug\";\n\nexport default {\n  plugins: [pluginPug()],\n};\n```\n\n### Using Pug Templates\n\nAfter the plugin registration is completed, Rsbuild will automatically parse template files with the `.pug` extension and compile them using the Pug template engine.\n\nFor example, first create a `src/index.pug` file, and point to that file using `html.template`:\n\n```ts title=\"rsbuild.config.ts\"\nexport default {\n  html: {\n    template: \"./src/index.pug\",\n  },\n};\n```\n\nThen, you can use Pug syntax in the `index.pug` template:\n\n```html\n\u003c!-- Input --\u003e\np Hello #{text}!\n\n\u003c!-- Output --\u003e\n\u003cp\u003eHello World!\u003c/p\u003e\n```\n\nPlease refer to the [Pug documentation](https://github.com/pugjs/pug) for a complete understanding of Pug's usage.\n\n### Using in Vue\n\nWhen using Vue, you can use Pug syntax in the template of `.vue` files:\n\n```vue title=\"App.vue\"\n\u003ctemplate lang=\"pug\"\u003e\nbutton.my-button(@click='count++') Count is: {{ count }}\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport { ref } from \"vue\";\n\nexport default {\n  setup() {\n    const count = ref(0);\n\n    return {\n      count,\n    };\n  },\n};\n\u003c/script\u003e\n```\n\n## Options\n\n### pugOptions\n\nUsed to set the compilation options for Pug. For detailed options, please refer to the [Pug API Reference](https://pugjs.org/api/reference.html#options).\n\n- **Type:** `Object | Function | undefined`\n- **Default:**\n\n```ts\nconst defaultOptions = {\n  doctype: \"html\",\n  compileDebug: false,\n};\n```\n\n- **Example 1:** Pass in a configuration object that will be merged with the default options using `Object.assign`.\n\n```ts\npluginPug({\n  pugOptions: {\n    doctype: \"xml\",\n  },\n});\n```\n\n- **Example 2:** Pass in a configuration function. The default configuration will be passed as the first argument, and you can directly modify the configuration object or return a value as the final result.\n\n```ts\npluginPug({\n  pugOptions(config) {\n    config.doctype = \"xml\";\n  },\n});\n```\n\n## License\n\n[MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-pug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-pug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-pug/lists"}