babel-plugin-styled-components-require

Babel plugin that adds styled-components import declaration

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-styled-components-require
1301.1.07 years ago7 years agoMinified + gzip package size for babel-plugin-styled-components-require in KB

Readme

babel-plugin-styled-components-require

Build
Status npm
 
Babel plugin that adds styled-components import declaration.
 

Example

Your component.js that contains this code:
const Card = styled.div`
  background: #FFF;
  border: 1px solid #DDD;
  border-radius: 2px;
  padding: 10px;
`;
export default Card;

will be transpiled to:
import styled from 'styled-components';

const Card = styled.div`
  background: #FFF;
  border: 1px solid #DDD;
  border-radius: 2px;
  padding: 10px;
`;
export default Card;

 

Usage

npm install babel-plugin-styled-components-require --save-dev
Add styled-components-require into .babelrc
{
  "plugins": [
    "styled-components-require"
  ]
}

 

Tests

✓ add import statement if styled.* is present
✓ do not add to already transpiled code
✓ do not add import styled-components twice
✓ do not add if it already imported
 

You like?

:star: this repo
 

License

MIT © siddharthkp