Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing styles using styled-components #1309

Closed
ikhudo opened this issue Mar 6, 2019 · 2 comments
Closed

Missing styles using styled-components #1309

ikhudo opened this issue Mar 6, 2019 · 2 comments
Labels

Comments

@ikhudo
Copy link

ikhudo commented Mar 6, 2019

trying to setup a lib of react components using styled components and react-styleguidist, I've created 3 components like this

import React from 'react'
import styled from 'styled-components'
const Wrapper = styled.div`
  color: red;
  background-color: yellow;
`
export default function SampleComponent() {
  return <Wrapper>This is sample component</Wrapper>
}

and when I run styleguidist server there only last component on the page is styled (has red text on yellow background).

// styleguide.config.js
module.exports = {
  components: 'packages/**/index.js',
  ignore: ['**/node_modules/**', '**/lib/**', '**/src/**'],
  webpackConfig: {
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: require.resolve('babel-loader'),
        },
      ],
    },
  },
}
// balel.config.js
module.exports = {
  presets: [
    [
      '@babel/env',
      {
        modules: false,
        useBuiltIns: 'usage',
      },
    ],
    '@babel/react',
  ],
  plugins: ['babel-plugin-styled-components'],
}

but it works if i run styleguidist build

@kopax
Copy link
Collaborator

kopax commented Mar 7, 2019

Hi, not sure if that help but:

  • you don't need the babel-plugin-styled-components for development, nor distrubution, I suggest you tu use it only in production

Also, we already shared a UI library for react-styleguidist (called @bootstrap-styled/rsg-components). It is build on top of bootstrap-styled which is built on top of styled-components.

You can see how we configured the thing, you might get your answer. Is your project on Github? I agree styled is a better starting choice for doing css-in-js.

Also, you might be interested in this extensions (doc) that bring other features such as layout package for building documentations.

@stale
Copy link

stale bot commented Jun 5, 2019

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

@stale stale bot added the wontfix label Jun 5, 2019
@stale stale bot closed this as completed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants