A babel-plugin-macros macro for styled-components that enables using styled-components without explicit Babel configuration. Version 1.0.0 is the current stable release. This macro integrates styled-components with create-react-app and other zero-config setups by leveraging babel-plugin-macros. It transforms styled-components at compile time, providing features like minified CSS class names and server-side rendering support. Unlike the traditional styled-components Babel plugin, this macro works automatically in environments where babel-plugin-macros is already configured, such as CRA, without additional Babel plugin setup.
npm install styled-components.macroVerified import paths — ran on the pinned version, not inferred.
Shows how to set up and use styled-components.macro with a Babel macro configuration file.
Always import styled and css from 'styled-components.macro', not 'styled-components'.
Install babel-plugin-macros and add 'macros' to your Babel plugins list in .babelrc or equivalent.
Consider using styled-components directly with babel-plugin-styled-components or rely on CRA's native support for styled-components.
Import ThemeProvider, createGlobalStyle, and keyframes directly from 'styled-components' instead of 'styled-components.macro'.
Run 'npm install --save-dev styled-components.macro' or 'yarn add styled-components.macro --dev'.
Ensure import is 'styled from 'styled-components.macro'' and that babel-plugin-macros is set up (see .babelrc).
Install the package and verify its name in node_modules. Ensure it's a devDependency.
Ensure styled-components version >=2 and babel-plugin-styled-components is installed if needed.