Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Importing module which uses styled-jsx throws import error in css/sass #1

Open
afzal273 opened this issue May 4, 2018 · 1 comment

Comments

@afzal273
Copy link

afzal273 commented May 4, 2018

Hello I have a react components module that uses styled-jsx and styled-jsx-plugin-sass; now I'm importing components from that module into my next project using next-plugin-transpile-modules, but I'm getting this error when a component uses styles that have imports in them.

Module build failed: Error: .../node_modules/test-react-styled-jsx-components/components/styles/buttons.css: File to import not found or unreadable: variables

buttons.css looks like this

@import 'variables';

.rdc-btn {
  font-weight: 500;
  padding: 0.75em 1.5em;
  display: inline-block;
  border-radius: $border-radius;
  border: 1px solid $color-dark;
  font-size: 1em;
  cursor: pointer;
  &:hover {
     background: blue;
 }
}

Variables is a sass file (_variables.sass)

Inside button component we do

import PropTypes from 'prop-types';

import styles from './styles/buttons.css';

const Button = ({children, ...rest }) => (
  <button className="rdc-btn" {...rest}>
    <style jsx>{styles}</style>
    {children}
  </button>
);

export default Button;```

This component works fine when imported in the same project, but throwing the error when used in another module that is using this module.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants