{"id":14377792,"url":"https://github.com/rspack-contrib/rsbuild-plugin-styled-components","last_synced_at":"2025-04-14T10:13:41.562Z","repository":{"id":252531931,"uuid":"840697651","full_name":"rspack-contrib/rsbuild-plugin-styled-components","owner":"rspack-contrib","description":"An Rsbuild plugin to provides compile-time support for styled-components.","archived":false,"fork":false,"pushed_at":"2025-04-01T13:03:57.000Z","size":101,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T10:13:35.853Z","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-08-10T12:09:46.000Z","updated_at":"2025-04-01T13:03:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"41db9385-64e4-4f92-8b9b-b44a103f926a","html_url":"https://github.com/rspack-contrib/rsbuild-plugin-styled-components","commit_stats":null,"previous_names":["rspack-contrib/rsbuild-plugin-styled-components"],"tags_count":4,"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-styled-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-styled-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-styled-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-styled-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rsbuild-plugin-styled-components/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-08-28T10:00:52.895Z","updated_at":"2025-04-14T10:13:41.553Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"readme":"# @rsbuild/plugin-styled-components\n\nAn Rsbuild plugin to provide compile-time support for styled-components. It improves debugging and adds server-side rendering support for styled-components.\n\n[styled-components](https://styled-components.com/) is a popular CSS-in-JS implementation library, which uses the new JavaScript feature [Tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) to write component CSS styles.\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/@rsbuild/plugin-styled-components\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/@rsbuild/plugin-styled-components?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## Notice\n\nThis Rsbuild plugin is simply a wrapper for [@swc/plugin-styled-components](https://www.npmjs.com/package/@swc/plugin-styled-components).\n\nIf you have any requirements, it is recommended to file an issue to [SWC plugins repo](https://github.com/swc-project/plugins) or the styled-components repo.\n\n## Usage\n\nInstall:\n\n```bash\n# `@rsbuild/core` \u003e= 1.2.0\nnpm add @rsbuild/plugin-styled-components -D\n\n# `@rsbuild/core` \u003c 1.2.0\nnpm add @rsbuild/plugin-styled-components@1.1.0 -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginStyledComponents } from \"@rsbuild/plugin-styled-components\";\n\nexport default {\n  plugins: [pluginStyledComponents()],\n};\n```\n\n## Example\n\nAfter registering the plugin, you can use styled-components to write styles:\n\n```ts\nimport styled from \"styled-components\";\n\nconst div = styled.div`\n  color: red;\n`;\n\nconsole.log(\"div\", div);\n```\n\n## Options\n\nIf you need to customize the compilation behavior of `styled-components`, you can use the following configs.\n\nYou can check the [styled-components documentation](https://styled-components.com/) to learn how to use it.\n\n- **Type:**\n\n```ts\ntype StyledComponentsOptions = {\n  displayName?: boolean;\n  ssr?: boolean;\n  fileName?: boolean;\n  meaninglessFileNames?: string[];\n  namespace?: string;\n  topLevelImportPaths?: string[];\n  transpileTemplateLiterals?: boolean;\n  minify?: boolean;\n  pure?: boolean;\n  cssProps?: boolean;\n};\n```\n\n- **Default:**\n\n```ts\n{\n  displayName: true,\n  // `isSSR` is true in SSR build\n  ssr: isSSR,\n  // `pure` is enabled in production to reduce bundle size\n  pure: isProd,\n  transpileTemplateLiterals: true,\n}\n```\n\n- **Example:**\n\nWhen the value is an Object, use the `Object.assign` function to merge with the default config.\n\n```ts title=\"rsbuild.config.ts\"\npluginStyledComponents({\n  pure: true,\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-styled-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-styled-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-styled-components/lists"}