Skip to content

Commit c6a6ee6

Browse files
committed
typescript-react-css-modules-demo
1 parent 9528997 commit c6a6ee6

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/hello.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.title {
2+
font-size: 40px;
3+
color:red;
4+
}

src/hello.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import React, { FC } from 'react';
1+
import React, {FC} from 'react';
2+
import styles from './hello.css';
23

3-
type Props = {};
4-
5-
export const Hello: FC<Props> = ({}) => {
4+
export const Hello: FC = () => {
65
return <div>
7-
<h1>Hello React</h1>
6+
<h1 className={styles.title}>Hello React</h1>
87
</div>;
98
}

webpack.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Configuration } from 'webpack';
1+
import {Configuration} from 'webpack';
22
import HtmlWebpackPlugin from 'html-webpack-plugin';
33
import path from 'path';
44

@@ -18,7 +18,11 @@ const config: Configuration = {
1818
test: /\.tsx?$/,
1919
loader: 'ts-loader',
2020
exclude: /node_modules/
21-
}]
21+
}, {
22+
test: /\.css$/,
23+
loader: ['style-loader', 'css-loader'],
24+
}
25+
]
2226
},
2327
plugins: [
2428
new HtmlWebpackPlugin() as any

0 commit comments

Comments
 (0)