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 css-modules exported variables? #4502

Closed
raptoria opened this issue May 22, 2018 · 4 comments
Closed

using css-modules exported variables? #4502

raptoria opened this issue May 22, 2018 · 4 comments

Comments

@raptoria
Copy link

raptoria commented May 22, 2018

Hi all, I'm new to CRA.
I see that the example boilerplate is importing the css like so,
import './App.css';

when I attempt to import the CSS as a variable, eg.
import * as styles from './App.css';

<header className="App-header" style={{background:styles.specialwhite}}>

I get the error, 'Cannot find module ./App.css'

I'm using Typescript. Any ideas on how to get this to work? I'd prefer not to use requires. I don't see .css.d.ts being generated anywhere. Is there a way to specify this without ejecting CRA and adding typed-css-modules?

@bugzpodder
Copy link

Hi raptoria, CSS modules is a breaking change and you'd need to use CRA 2.0 in order to get it to work.
Please see #3815 on a list of changes supported in CRA 2 as well as how to get an alpha build to test out.

@raptoria
Copy link
Author

I'm using react-script-ts. I poked around that package.json and I can't see what version of CRA it's using. The react-script-ts I'm using is version 2.15.1. Is there another way to use CRA V 2.0 with typescript other than react-script-ts?

@bugzpodder
Copy link

i believe react-script-ts is a fork of react-scripts, and they have yet to merge any changes from CRA v2. You can follow along: wmonk/create-react-app-typescript#284

@Timer
Copy link
Contributor

Timer commented May 22, 2018

Hi @raptoria!
Like @bugzpodder said, this feature is only available in react-scripts@^2 (currently in beta); react-scripts-ts is a completely different project which is long-ago forked from react-scripts.
You can subscribe to wmonk/create-react-app-typescript#284 for updates.

Sorry we couldn't be more helpful!

edit: also -- there's no other way to use typescript, sorry.

@Timer Timer closed this as completed May 22, 2018
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants