{"id":19071796,"url":"https://github.com/yunsii/unplugin-polish-tagged-templates","last_synced_at":"2025-04-28T15:50:14.872Z","repository":{"id":190772367,"uuid":"683260108","full_name":"yunsii/unplugin-polish-tagged-templates","owner":"yunsii","description":"Remove unnecessary tagged templates at compile time.","archived":false,"fork":false,"pushed_at":"2024-09-20T04:29:17.000Z","size":937,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T18:32:41.262Z","etag":null,"topics":["rollup","tagged-template","tagged-template-literals","unplugin","vite","webpack"],"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/yunsii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"open_collective":"yuns","custom":["https://afdian.net/@yunslove"]}},"created_at":"2023-08-26T02:23:59.000Z","updated_at":"2024-09-20T04:29:20.000Z","dependencies_parsed_at":"2023-08-26T09:24:50.641Z","dependency_job_id":"d8353e8b-bed6-40e4-a527-b1fd95eed932","html_url":"https://github.com/yunsii/unplugin-polish-tagged-templates","commit_stats":null,"previous_names":["yunsii/unplugin-polish-tagged-templates"],"tags_count":11,"template":false,"template_full_name":"yunsii/unplugin-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunsii%2Funplugin-polish-tagged-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunsii%2Funplugin-polish-tagged-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunsii%2Funplugin-polish-tagged-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunsii%2Funplugin-polish-tagged-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yunsii","download_url":"https://codeload.github.com/yunsii/unplugin-polish-tagged-templates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342700,"owners_count":21574242,"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":["rollup","tagged-template","tagged-template-literals","unplugin","vite","webpack"],"created_at":"2024-11-09T01:31:07.119Z","updated_at":"2025-04-28T15:50:14.830Z","avatar_url":"https://github.com/yunsii.png","language":"TypeScript","funding_links":["https://opencollective.com/yuns","https://afdian.net/@yunslove"],"categories":[],"sub_categories":[],"readme":"# unplugin-polish-tagged-templates\n\n[![NPM version](https://img.shields.io/npm/v/unplugin-polish-tagged-templates?color=a1b858\u0026label=)](https://www.npmjs.com/package/unplugin-polish-tagged-templates) [![Download monthly](https://img.shields.io/npm/dm/unplugin-polish-tagged-templates.svg)](https://www.npmjs.com/package/unplugin-polish-tagged-templates)\n\nRemove unnecessary [tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) at compile time.\n\n## Features\n\n- 🦄 [Unified plugin](https://github.com/unjs/unplugin), support Vite/Rollup/Webpack/Nuxt/esbuild\n- 💎 polish **class names** tagged templates as preset\n  - Support comment start with `//`\n- 🛠️ Custom tagged templates to polish\n\n\u003e Only polish tagged templates in non-development environment.\n\n## Example\n\nWith the config:\n\n```tsx\npolishTaggedTemplates({\n  clsTags: ['cls'],\n})\n```\n\nIt will polish code from:\n\n```tsx\nconst className = cls`\n  cursor-pointer\n  font-bold text-xl\n  // comment here\n  text-sky-500\n  hover:text-sky-600\n`\n\nfunction Component() {\n  return (\n    \u003cp\n      className={cls`\n        cursor-pointer\n        font-bold text-xl\n        // comment here\n        text-sky-500\n        hover:text-sky-600\n      `}\n      // ...\n    \u003e\n      Hi\n    \u003c/p\u003e\n  )\n}\n```\n\nto\n\n```tsx\nconst className = 'cursor-pointer font-bold text-xl text-sky-500 hover:text-sky-600'\n\nfunction Component() {\n  return (\n    \u003cp\n      className='cursor-pointer font-bold text-xl text-sky-500 hover:text-sky-600'\n      // ...\n    \u003e\n      Hi\n    \u003c/p\u003e\n  )\n}\n```\n\nHowever, there is no effect if tagged templates has any expressions.\n\nThis plugin make you free to use tagged templates to composite class name or others aims, and remove unnecessary tagged templates at compile time.\n\n\u003e [!TIP]\n\u003e For better compile performance, you'd better reduce using nested tagged templates as much as possible.\n\n## Install\n\n```bash\nnpm i unplugin-polish-tagged-templates\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport polishTaggedTemplates from 'unplugin-polish-tagged-templates/vite'\n\nexport default defineConfig({\n  plugins: [\n    polishTaggedTemplates({\n      /* options */\n    }),\n  ],\n})\n```\n\nExample: [`playground/`](./playground/)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rollup.config.js\nimport polishTaggedTemplates from 'unplugin-polish-tagged-templates/rollup'\n\nexport default {\n  plugins: [\n    polishTaggedTemplates({\n      /* options */\n    }),\n  ],\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// webpack.config.js\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require('unplugin-polish-tagged-templates/webpack')({\n      /* options */\n    }),\n  ],\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eNuxt\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// nuxt.config.js\nexport default defineNuxtConfig({\n  modules: [\n    [\n      'unplugin-polish-tagged-templates/nuxt',\n      {\n        /* options */\n      },\n    ],\n  ],\n})\n```\n\n\u003e This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vue.config.js\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      require('unplugin-polish-tagged-templates/webpack')({\n        /* options */\n      }),\n    ],\n  },\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// esbuild.config.js\nimport { build } from 'esbuild'\nimport polishTaggedTemplates from 'unplugin-polish-tagged-templates/esbuild'\n\nbuild({\n  plugins: [polishTaggedTemplates()],\n})\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Related\n\n- [tagged-classnames-free](https://github.com/yunsii/tagged-classnames-free) - Free to tagged classnames.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunsii%2Funplugin-polish-tagged-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyunsii%2Funplugin-polish-tagged-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunsii%2Funplugin-polish-tagged-templates/lists"}