
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
@rsbuild/plugin-styled-components
Advanced tools
An Rsbuild plugin to provide compile-time support for styled-components. It improves debugging and adds server-side rendering support for styled-components.
An Rsbuild plugin to provide compile-time support for styled-components. It improves debugging and adds server-side rendering support for styled-components.
styled-components is a popular CSS-in-JS implementation library, which uses the new JavaScript feature Tagged template to write component CSS styles.
This Rsbuild plugin is simply a wrapper for @swc/plugin-styled-components.
If you have any requirements, it is recommended to file an issue to SWC plugins repo or the styled-components repo.
Install:
# `@rsbuild/core` >= 1.2.0
npm add @rsbuild/plugin-styled-components -D
# `@rsbuild/core` < 1.2.0
npm add @rsbuild/plugin-styled-components@1.1.0 -D
Add plugin to your rsbuild.config.ts
:
// rsbuild.config.ts
import { pluginStyledComponents } from "@rsbuild/plugin-styled-components";
export default {
plugins: [pluginStyledComponents()],
};
After registering the plugin, you can use styled-components to write styles:
import styled from "styled-components";
const div = styled.div`
color: red;
`;
console.log("div", div);
If you need to customize the compilation behavior of styled-components
, you can use the following configs.
You can check the styled-components documentation to learn how to use it.
type StyledComponentsOptions = {
displayName?: boolean;
ssr?: boolean;
fileName?: boolean;
meaninglessFileNames?: string[];
namespace?: string;
topLevelImportPaths?: string[];
transpileTemplateLiterals?: boolean;
minify?: boolean;
pure?: boolean;
cssProps?: boolean;
};
{
displayName: true,
// `isSSR` is true in SSR build
ssr: isSSR,
// `pure` is enabled in production to reduce bundle size
pure: isProd,
transpileTemplateLiterals: true,
}
When the value is an Object, use the Object.assign
function to merge with the default config.
pluginStyledComponents({
pure: true,
});
MIT.
FAQs
An Rsbuild plugin to provide compile-time support for styled-components. It improves debugging and adds server-side rendering support for styled-components.
The npm package @rsbuild/plugin-styled-components receives a total of 9,590 weekly downloads. As such, @rsbuild/plugin-styled-components popularity was classified as popular.
We found that @rsbuild/plugin-styled-components demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.