Skip to content
This repository was 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

@afzal273

Description

@afzal273

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions