react-app-rewire-css-modules | This project | Frontend Framework library
kandi X-RAY | react-app-rewire-css-modules Summary
kandi X-RAY | react-app-rewire-css-modules Summary
This project is archived. Create React App v2 introduced support for CSS Modules. We recommend using the native support for CSS Modules instead of this project.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-app-rewire-css-modules
react-app-rewire-css-modules Key Features
react-app-rewire-css-modules Examples and Code Snippets
Community Discussions
Trending Discussions on react-app-rewire-css-modules
QUESTION
I'm creating the initial setup of a proof of concept project using ReactJS and typescript, and I'd like to include the CSS modules in it without having to eject the webpack configuration.
Here are the steps I followed so far:
- npm install -g create-react-app
- create-react-app firstapp --scripts-version=react-scripts-ts
- npm install react-app-rewired --save-dev
- npm install --save-dev codebandits/react-app-rewire-css-modules sass-loader node-sass
- package.json: "start": "react-app-rewired start --scripts-version react-scripts-ts"
config-overrides.js:
const rewireCssModules = require('react-app-rewire-css-modules'); module.exports = function override(config, env){ config = rewireCssModules(config, env);
return config; }
I correctly set my App.module.scss file, and referenced it in my App.tsx file:
import styles from './App.module.scss';
When I run the project, I have an error regarding the css module: Cannot find module './App.module.scss'.
When I do the exact same project without the typescript configuration, it works though.
What should I change for the CSS modules to be taken into account?
I came accross typings-for-css-modules-loader, but I'm not sure how to integrate it in my configuration since I didn't eject the webpack configuration.
Thanks in advance,
Thomas .T
EDIT 1: I added a global.d.ts file with:
declare module '*.css'
declare module '*.scss'
And it did the trick. I didn't use typings-for-css-modules-loader in the end.
The answer comes from this article: https://hackernoon.com/zero-config-react-typescript-css-modules-jest-with-poi-bbcedfe2383a
...ANSWER
Answered 2018-Jun-08 at 04:22I added a global.d.ts file with:
- declare module '*.css'
- declare module '*.scss'
And it did the trick. I didn't use typings-for-css-modules-loader in the end.
The answer comes from this article: https://hackernoon.com/zero-config-react-typescript-css-modules-jest-with-poi-bbcedfe2383a
Gonna accept this as an answer within 2 days.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-app-rewire-css-modules
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page