{"id":13493803,"url":"https://github.com/aMarCruz/rollup-plugin-pug","last_synced_at":"2025-03-28T12:32:35.010Z","repository":{"id":46131743,"uuid":"66743290","full_name":"aMarCruz/rollup-plugin-pug","owner":"aMarCruz","description":"Rollup plugin that transforms pug templates in es6 modules.","archived":false,"fork":false,"pushed_at":"2021-11-11T18:51:12.000Z","size":102,"stargazers_count":27,"open_issues_count":8,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-14T18:20:09.481Z","etag":null,"topics":["jade","plugin","pug","rollup","rollup-plugin","template"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/aMarCruz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-08-28T01:24:15.000Z","updated_at":"2024-03-12T04:11:24.000Z","dependencies_parsed_at":"2022-09-26T18:30:57.073Z","dependency_job_id":null,"html_url":"https://github.com/aMarCruz/rollup-plugin-pug","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-pug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-pug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-pug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-pug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aMarCruz","download_url":"https://codeload.github.com/aMarCruz/rollup-plugin-pug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222144079,"owners_count":16938448,"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":["jade","plugin","pug","rollup","rollup-plugin","template"],"created_at":"2024-07-31T19:01:18.942Z","updated_at":"2024-10-31T08:31:16.802Z","avatar_url":"https://github.com/aMarCruz.png","language":"JavaScript","funding_links":["https://ko-fi.com/C0C7LF7I"],"categories":["JavaScript","Plugins"],"sub_categories":["Templating"],"readme":"# rollup-plugin-pug\n\n[![License][license-image]][license-url]\n[![npm Version][npm-image]][npm-url]\n[![Linux build Status][build-image]][build-url]\n[![Windows build status][appveyor-image]][appveyor-url]\n\n[Rollup](https://github.com/rollup/rollup) plugin that transforms [Pug](https://pugjs.org) v2 templates to ES6 modules.\n\n- Dynamic generation of HTML. Static HTML is optional and configurable.\n- Automatic `import` of the pug-runtime in your bundle, if required.\n- Automatic `import` of template `extends` and `includes`.\n- Source map support.\n- Support for ES6 `import` statements (moved out of the template).\n- Typescript v3.x definitions.\n\n## IMPORTANT\n\nv1.1 requires Rollup 0.61 and node.js 6 or later, for previous versions use rollup-plugin-pug 0.1.6\n\n## Installation\n\n```bash\nnpm install rollup-plugin-pug --save-dev\n```\n\n## Usage\n\nCreate the template\n\n```jade\n//- template.pug\np= message\n```\n\nand import it as any other function:\n\n```js\nimport templateFn from './template.pug';\n\nconst context = { message: 'Hello World' };\n\nconsole.log(templateFn(context));  // \u003cp\u003eHello World\u003c/p\u003e\n```\n\nor rename it for static compilation and import it as string:\n\n```js\nimport htmlString from './template.static.pug';\n\nconsole.log(htmlString);  // \u003cp\u003eHello World\u003c/p\u003e\n```\n\nBuild with something like...\n\n```js\nimport { rollup } from 'rollup';\nimport pug from 'rollup-plugin-pug';\n\nrollup({\n  entry: 'src/main.js',\n  plugins: [\n    pug({\n      locals: { message: 'Hello World' }\n    })\n  ]\n}).then(...)\n```\n\nThat's it.\n\n## Options\n\nIn addition to the regular pug options, the plugin defines these:\n\n- `staticPattern` - Regex for files to compile and evaluate at build time to export plain HTML.\n- `locals` - Plain JavaScript object with values passed to the compiler for static compilation (Deprecated).\n- `include` - minimatch or array of minimatch with files that should be included by default.\n- `exclude` - minimatch or array of minimatch with files that should be excluded by default.\n- `extensions` - Array of extensions to process (don't use wildcards here).\n- `pugRuntime` - Custom Pug runtime filename (See note).\n- `sourceMap` - Enabled by default.\n\n**TIP:** Use `staticPattern: /\\S/` to evaluate all the templates at build time.\n\n### Be carefull\n\nThe parameter passed to the static templates is a shallow copy of the plugin options. Do not change it unless you know what you doing.\n\nWhen a template matches the `staticPattern` regex, the template is executed at complie-time and you load the resulting string through `import` at runtime, so it will not have access to runtime variables or methods. Instead, the plugin passes its options to the template at compile-time.\n\n## Default Options\n\nThe plugin has preset the following options:\n\n```js\n{\n  doctype: 'html',\n  basedir: absolute(input),       // absolute path of the rollup `input` option\n  compileDebug: false,            // `true` is recommended for development\n  sourceMap: true,                // with or without compileDebug option\n  inlineRuntimeFunctions: false,  // use the pug runtime\n  extensions: ['.pug', '.jade'],\n  staticPattern: /\\.static\\.(?:pug|jade)$/\n}\n```\n\nSee the full list and explanation in the [API Documentation](https://pugjs.org/api/reference.html) of the pug site.\n\nNote: The default of `staticPattern` was defined to be compatibile with the old Jade plugin and so it has remained, but I prefer `/\\.html\\.pug$/`.\n\n## Custom runtime\n\nThe `pugRuntime` option can be set to `false` to avoid importing the runtime, but you must provide an equivalent `pug` object accessible to the template:\n\nDisable the predefined runtime in rollup.config.js\n\n```js\n  ...\n  plugins: [\n    pug({ pugRuntime: false })\n  ]\n```\n\nand import the yours in your .pug files\n\n```jade\n- import pug from 'my-runtime'\np= name\n//- ...etc\n```\n\nbut the recommended option is name it in the config:\n\n```js\n  // in rollup.config.js\n   ...\n   plugins: [\n     pug({ pugRuntime: 'my-runtime' })\n   ]\n```\n\nSearch for \"pugRuntime\" in the `test/run.js` file to see examples.\n\n## What's New\n\n### v1.1.1\n\n- #14: fix (this.warn is not a function) - thanks to @leptonix\n\nSee the [CHANGELOG](CHANGELOG.md) for more changes.\n\n## Support my Work\n\nI'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time and effort so, if you like my work, please consider...\n\n\u003c!-- markdownlint-disable MD033 --\u003e\n\n[\u003cimg src=\"https://amarcruz.github.io/images/kofi_blue.png\" height=\"36\" title=\"Support Me on Ko-fi\" /\u003e][kofi-url]\n\nOf course, feedback, PRs, and stars are also welcome 🙃\n\nThanks for your support!\n\n[build-image]:    https://travis-ci.org/aMarCruz/rollup-plugin-pug.svg?branch=master\n[build-url]:      https://travis-ci.org/aMarCruz/rollup-plugin-pug\n[appveyor-image]: https://ci.appveyor.com/api/projects/status/us75417f6ls7yjik/branch/master?svg=true\n[appveyor-url]:   https://ci.appveyor.com/project/aMarCruz/rollup-plugin-pug/branch/master\n[npm-image]:      https://img.shields.io/npm/v/rollup-plugin-pug.svg\n[npm-url]:        https://www.npmjs.com/package/rollup-plugin-pug\n[license-image]:  https://img.shields.io/npm/l/express.svg\n[license-url]:    https://github.com/aMarCruz/rollup-plugin-pug/blob/master/LICENSE\n[kofi-url]:       https://ko-fi.com/C0C7LF7I\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Frollup-plugin-pug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FaMarCruz%2Frollup-plugin-pug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Frollup-plugin-pug/lists"}