How to use css modules
See original GitHub issueIs there a way to use css modules with docz?
Description
I’m using css modules with the webpack loader css-loader
here is a component for an exemple
import * as React from 'react'
import classNames from 'classnames'
const styles = require('./styles.css')
interface State {
isFocused: boolean
}
export default class TextField extends React.Component<{}, State> {
public constructor(props: {}) {
super(props)
this.state = {
isFocused: false
}
}
private onFocus = () => {
this.setState({ isFocused: true })
}
private onBlur = () => {
this.setState({ isFocused: false })
}
public render() {
return <div className={styles.container}>
<input className={styles.input}
onFocus={this.onFocus}
onBlur={this.onBlur} />
<label className={classNames(styles.label, this.state.isFocused ? styles.labelFocus : {})}>label</label>
</div >
}
}
and my very simple mdx file
---
name: TextField
---
import {Playground } from 'docz'
import TextField from './'
# TextField
<Playground>
<TextField />
</Playground>
when I start docz dev server, I have this error message
ERROR Failed to compile with 1 errors 09:39:00
error in ./src/libs/text-field/text.mdx
Module build failed (from ./node_modules/@mdx-js/loader/index.js):
Error: ENOENT: no such file or directory, open '/Users/bgranger/htdocs/perso/pocs/docz/src/libs/text-field/text.mdx'
@ ./.docz/app/imports.js 9:11-123
@ ./.docz/app/index.jsx
@ multi ./node_modules/babel-polyfill/lib/index.js ./.docz/app/index.jsx
I assume that the css loader is not used with the bundler.
I have two questions:
- is it possible to use css modules?
- if not is it possible to use custom bundler/bundler config?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Using CSS Modules in React - Programming with Mosh
First, create a normal CSS file. · Add CSS classes to this file. · Import the module you've just created from within your...
Read more >Using CSS modules in React - Bootcamp
A CSS Module is simply a .css file, where classes act similarly to local variables in Javascript. It is a tool that makes...
Read more >What are CSS Modules and how to use it in React - UseCSV
CSS Modules are "CSS files in which all class names and animation names are scoped locally by default". Instead of having CSS files...
Read more >Adding a CSS Modules Stylesheet - Create React App
CSS Modules let you use the same CSS class name in different files without worrying about naming clashes. Learn more about CSS Modules...
Read more >Using CSS Modules in React - OpenReplay Blog
Using CSS Modules in React ... In React js, where classes function similarly to local variables in JavaScript, a CSS Module is just...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try to make your config like that @S-unya:
After released v0.2.11 you can use docz-plugin-css to configure your CSS just by adding a plugin ✌️
@S-unya @bastienGranger