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

Using @value in composes failing #83

Open
sidhu663 opened this issue Feb 9, 2017 · 3 comments
Open

Using @value in composes failing #83

sidhu663 opened this issue Feb 9, 2017 · 3 comments

Comments

@sidhu663
Copy link

sidhu663 commented Feb 9, 2017

//theme.css
.smallText {
font-size: 10px;
}

//style.css
@value theme: 'theme.css';

.myClass {
composes: smallText from theme;
}

The above example results in a "Module build failed: referenced class name "smallText" in composes not found"

Using webpack

Assigning the import to a value first works fine:

//style.css
@value theme: 'theme.css';
@value smallText from theme;

.myClass {
composes: smallText
}

@josephrexme
Copy link

josephrexme commented Mar 27, 2017

I have the exact same issue. I had to compose directly from the path:

.myclass{
  composes: smallText from './';
}

and in the case of inheriting the variable name

@value myColor from './theme.css';
.myclass{
  background: myColor;
}

@tivac
Copy link

tivac commented Mar 27, 2017

I ran into this with modular-css and had to fix it by splitting up value-processing into a two-pass thing, where it does local values (like @value foo: "./foo.css";) first and then processing values/compositions imported from other files.

Kinda of a PITA, but it worked out ok.

@DavideDaniel
Copy link

DavideDaniel commented Apr 12, 2017

yep, same...

/* colors.css */
@value primary: rgba(255,215,237,1);
.primaryColor {
  color: primary;
  fill: primary;
}

then:

/* styles.css */
@value colors: "../colors.css";
@value primary, secondary from colors;
/* the following works */
.header {
  background-color: primary;
}
/* the following results in error */
.header {
  composes: primaryColor from colors;
}

Error message:
"Module build failed: referenced class name "primaryClass" in composes not found"

EDIT:
I think what's happening is related to the things discussed in Evaneos/vitaminjs#261 - I realized I was getting values feature from simply using css-modules and not even using a post-css loader. After adding postcss correctly, it still gave me the error until I tried this:

Solution:

@value primary, secondary from "../colors.css";

.header {
  composes: primaryColor from "../colors.css";
  background-color: secondary;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants