File tree 7 files changed +87
-6
lines changed
7 files changed +87
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "presets" : [" @babel/preset-env" , " @babel/preset-react" ],
3
- "plugins" : [
4
- " @babel/plugin-syntax-dynamic-import" ,
5
- " @babel/plugin-proposal-class-properties"
6
- ]
7
- }
2
+ "presets" : [" @babel/preset-env" , " @babel/preset-react" ],
3
+ "plugins" : [
4
+ " @babel/plugin-syntax-dynamic-import" ,
5
+ " @babel/plugin-proposal-class-properties"
6
+ ]
7
+ }
Original file line number Diff line number Diff line change 5
5
"main" : " index.js" ,
6
6
"license" : " MIT" ,
7
7
"private" : true ,
8
+ "scripts" : {
9
+ "start" : " webpack-dev-server"
10
+ },
8
11
"dependencies" : {
9
12
"react" : " ^17.0.2" ,
10
13
"react-dom" : " ^17.0.2"
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
8
+ </ link >
9
+ < title > webpack-for-react</ title >
10
+ </ head >
11
+
12
+ < body >
13
+ < div id ="root "> </ div >
14
+ </ body >
15
+
16
+ </ html >
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+
3
+ const App = ( ) => {
4
+ return < div > Hello React and Webpack</ div >
5
+ }
6
+
7
+ export default App
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom'
3
+ import App from './App'
4
+
5
+ ReactDOM . render ( < App /> , document . getElementById ( 'root' ) )
Original file line number Diff line number Diff line change
1
+ const webpack = require ( 'webpack' )
2
+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
3
+
4
+ const port = process . env . PORT || 3000
5
+
6
+ module . exports = {
7
+ mode : 'development' ,
8
+ entry : './src/index.js' ,
9
+ output : {
10
+ filename : 'bundle.[hash].js' ,
11
+ } ,
12
+ devtool : 'inline-source-map' ,
13
+ module : {
14
+ rules : [
15
+ {
16
+ test : / \. ( j s ) $ / ,
17
+ exclude : / n o d e _ m o d u l e s / ,
18
+ use : [ 'babel-loader' ] ,
19
+ } ,
20
+ {
21
+ test : / \. c s s $ / ,
22
+ use : [
23
+ {
24
+ loader : 'style-loader' ,
25
+ } ,
26
+ {
27
+ loader : 'css-loader' ,
28
+ options : {
29
+ modules : true ,
30
+ localsConvention : 'camelCase' ,
31
+ sourceMap : true ,
32
+ } ,
33
+ } ,
34
+ ] ,
35
+ } ,
36
+ ] ,
37
+ } ,
38
+ plugins : [
39
+ new HtmlWebpackPlugin ( {
40
+ template : 'public/index.html' ,
41
+ favicon : 'public/favicon.ico' ,
42
+ } ) ,
43
+ ] ,
44
+ devServer : {
45
+ host : 'localhost' ,
46
+ port : port ,
47
+ historyApiFallback : true ,
48
+ open : true ,
49
+ } ,
50
+ }
You can’t perform that action at this time.
0 commit comments