css-modules

Using Semantic UI With CSS Modules in Webpack

孤街浪徒 提交于 2019-12-02 05:18:38
问题 I have import 'semantic-ui-css/semantic.min.css' in index.js , as instructed by Semantic UI. Before I did yarn eject (to enable CSS modules with create-react-app ) everything worked fine, but as soon as I did I got the following error: Module not found: Can't resolve 'themes/default/assets/fonts/icons.eot' in '[MY_PROJECT_DIR]/node_modules/semantic-ui-css' I thought that it might be an issue with Webpack's loaders' not dealing with font files, so I found this: { test: /\.(eot|woff|woff2|ttf

Conditional Import based on environment variable

不问归期 提交于 2019-11-30 22:26:01
I have a react component which has X options for a stylesheet to be imported which is using CSS Modules. I ideally want to have a global environment variable fetched by using e.g. process.env.THEME I can't use: import MyStyleSheet from `${process.env.THEME}/my.module.css` I can use: const MyStyleSheet = require(process.env.THEME/my.module.css); however..... import/no-dynamic-require eslint rule kicks off saying its bad. https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md All the articles and posts I read say its not possible. Surely this is a common

How to use css modules with create-react-app?

北慕城南 提交于 2019-11-30 00:07:14
According to a tweet by Dan Abramov, CSS modules support is there in create-react-app (CRA). One just needs to give extension of module.css to his stylesheets to enable the feature, but this is not working with me. I am having version 1.1.4 of react-scripts . How can I enable css modules with CRA? Thanks You do not need to eject. Create-React-App supports css modules right out of the box as of version 2, which is now stable. Upgrade to v2 ( react-scripts@latest ) by running yarn upgrade react-scripts@latest . You just have to create a file with the extension .module.css For example: .myStyle {

How to use css modules with create-react-app?

别说谁变了你拦得住时间么 提交于 2019-11-27 11:37:14
问题 According to a tweet by Dan Abramov, CSS modules support is there in create-react-app (CRA). One just needs to give extension of module.css to his stylesheets to enable the feature, but this is not working with me. I am having version 1.1.4 of react-scripts . How can I enable css modules with CRA? Thanks 回答1: You do not need to eject. Create-React-App supports css modules right out of the box as of version 2, which is now stable. Upgrade to v2 (react-scripts@latest) by running yarn upgrade