File tree 9 files changed +166
-0
lines changed
9 files changed +166
-0
lines changed Original file line number Diff line number Diff line change
1
+ /node_modules
2
+ /build
Original file line number Diff line number Diff line change
1
+ Hi
Original file line number Diff line number Diff line change
1
+ .test {
2
+ background : tomato;
3
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ </ head >
5
+ < body >
6
+ < div id ="root "> </ div >
7
+ < script src ="main.js "> </ script >
8
+ </ body >
9
+ </ html >
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import ReactDOM from 'react-dom' ;
3
+
4
+ import Nested from './nested' ;
5
+
6
+ import './index.css' ;
7
+
8
+ // Import html file into build
9
+ require ( 'file?name=[name].[ext]!./index.html' )
10
+
11
+ class App extends React . Component {
12
+
13
+ constructor ( props ) {
14
+ super ( props ) ;
15
+ this . state = { } ;
16
+ }
17
+
18
+ render ( ) {
19
+ return (
20
+ < div styleName = 'test' >
21
+ Hello
22
+ < Nested />
23
+ </ div >
24
+ ) ;
25
+ }
26
+
27
+ }
28
+
29
+ ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
Original file line number Diff line number Diff line change
1
+ .test {
2
+ background : lightgreen ;
3
+ }
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import './index.scss' ;
4
+
5
+ class Nested extends React . Component {
6
+
7
+ constructor ( props ) {
8
+ super ( props ) ;
9
+ }
10
+
11
+ render ( ) {
12
+ return (
13
+ < div styleName = 'test' >
14
+ Nested
15
+ </ div >
16
+ ) ;
17
+ }
18
+
19
+ }
20
+
21
+ export default Nested ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " babel-plugin-react-css-modules-test" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Testing babel-plugin-react-css-modules" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "start" : " webpack-dev-server" ,
8
+ "build" : " webpack" ,
9
+ "test" : " echo \" Error: no test specified\" && exit 1"
10
+ },
11
+ "repository" : " https://github.com/ksrb/babel-plugin-react-css-modules-test" ,
12
+ "author" : " " ,
13
+ "license" : " ISC" ,
14
+ "devDependencies" : {
15
+ "autoprefixer" : " ^6.5.3" ,
16
+ "babel-cli" : " ^6.18.0" ,
17
+ "babel-loader" : " ^6.2.9" ,
18
+ "babel-plugin-react-css-modules" : " ^1.1.0" ,
19
+ "babel-preset-react-app" : " ^2.0.1" ,
20
+ "css-loader" : " ^0.26.1" ,
21
+ "file-loader" : " ^0.9.0" ,
22
+ "node-sass" : " ^3.13.0" ,
23
+ "postcss-loader" : " ^1.2.0" ,
24
+ "resolve-url-loader" : " ^1.6.0" ,
25
+ "sass-loader" : " ^4.0.2" ,
26
+ "style-loader" : " ^0.13.1" ,
27
+ "webpack" : " ^1.14.0" ,
28
+ "webpack-dev-server" : " ^1.16.2"
29
+ },
30
+ "dependencies" : {
31
+ "react" : " ^15.4.1" ,
32
+ "react-dom" : " ^15.4.1"
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ var path = require ( 'path' ) ;
2
+ var autoprefixer = require ( 'autoprefixer' ) ;
3
+
4
+ module . exports = {
5
+ entry : './index.js' ,
6
+ output : {
7
+ path : path . join ( __dirname , 'build' ) ,
8
+ filename : '[name].js' ,
9
+ } ,
10
+ module : {
11
+ loaders : [
12
+ {
13
+ test : / \. j s $ / ,
14
+ loader : 'babel' ,
15
+ exclude : / n o d e _ m o d u l e s / ,
16
+ query : {
17
+ presets : [ 'react-app' ] ,
18
+ plugins : [
19
+ [
20
+ 'react-css-modules' ,
21
+ {
22
+ generateScopedName : '[path]___[name]__[local]___[hash:base64:5]'
23
+ }
24
+ ] ,
25
+ ]
26
+ } ,
27
+ } ,
28
+ {
29
+ test : / \. c s s $ / ,
30
+ loaders : [
31
+ 'style' ,
32
+ 'css?importLoader=1&modules&localIdentName=[path]___[name]__[local]___[hash:base64:5]' ,
33
+ 'postcss' ,
34
+ ] ,
35
+ } ,
36
+ {
37
+ test : / \. s c s s $ / ,
38
+ loaders : [
39
+ 'style?sourceMap' ,
40
+ 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]' ,
41
+ 'resolve-url' ,
42
+ 'sass?sourceMap'
43
+ ]
44
+ }
45
+ ] ,
46
+ } ,
47
+
48
+ postcss : function ( ) {
49
+ return [
50
+ autoprefixer ( {
51
+ browsers : [
52
+ '>1%' ,
53
+ 'last 4 versions' ,
54
+ 'Firefox ESR' ,
55
+ 'not ie < 9' , // React doesn't support IE8 anyway
56
+ ]
57
+ } ) ,
58
+ ] ;
59
+ } ,
60
+
61
+ devServer : {
62
+ inline : true ,
63
+ } ,
64
+ } ;
You can’t perform that action at this time.
0 commit comments