1.0.0-0 • Published 6 years ago

styled-parser v1.0.0-0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

styled-parser

Parse information from styled-components modules

npm i styled-parser
const fs = require('fs')
const path = require('path')
const parse = require('styled-parser')

const componentSource = fs.readFileSync(
  path.join(__dirname, './src/Box.js')
)

const result = parse(componentSource)

Returns an object with the following:

  • name: default exported component name
  • type: HTML tag or React component type
  • style: string of the template literal argument
  • defaultProps: object of the component's defaultProps
  • imports: array of imports for the module

MIT License