This repository was archived by the owner on Feb 11, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import React from 'react';
3
3
import { render } from 'react-dom' ;
4
4
5
5
render (
6
- < h1 > Test</ h1 >
6
+ < h1 > Test</ h1 > ,
7
+ document . getElementById ( 'root' )
7
8
) ;
8
9
Original file line number Diff line number Diff line change 6
6
"build-dev" : " npm run clean && npm run build-client-dev" ,
7
7
"build-client-dev" : " node_modules/webpack/bin/webpack.js -d --progress --colors" ,
8
8
"clean" : " rimraf dist" ,
9
- "start" : " npm run build-dev && node server.js" ,
9
+ "start" : " npm run build-dev && node server.babel. js" ,
10
10
"test" : " echo \" Error: no test specified\" && exit 1"
11
11
},
12
12
"repository" : {
26
26
},
27
27
"homepage" : " https://github.com/coderkevin/redux-trigger" ,
28
28
"dependencies" : {
29
+ "express" : " ^4.13.3" ,
29
30
"react" : " ^0.14.3" ,
30
31
"react-dom" : " ^0.14.3" ,
31
32
"react-redux" : " ^4.0.5" ,
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This server file works to allow ES2015 syntax in server.js
3
+ */
4
+ require ( 'babel/register' ) ;
5
+ require ( './server' ) ;
Original file line number Diff line number Diff line change 1
- console . log ( 'Server placeholder.' ) ;
1
+ /**
2
+ * Sample Redux/React Server.
3
+ */
4
+ import webpack from 'webpack' ;
5
+ import webpackDevMiddleware from 'webpack-dev-middleware' ;
6
+ import webpackHotMiddleware from 'webpack-hot-middleware' ;
7
+ import express from 'express' ;
8
+ import config from './webpack.config' ;
9
+
10
+ const app = new express ( ) ;
11
+ const port = 3000 ;
12
+ const devConfig = {
13
+ noInfo : true ,
14
+ publicPath : config . output . publicPath
15
+ } ;
16
+
17
+ console . log ( 'Starting server.' ) ;
18
+
19
+ var compiler = webpack ( config ) ;
20
+ app . use ( webpackDevMiddleware ( compiler , devConfig ) ) ;
21
+ app . use ( webpackHotMiddleware ( compiler ) ) ;
22
+
23
+ app . get ( '/' , function ( req , res ) {
24
+ res . sendFile ( __dirname + '/index.html' ) ;
25
+ } ) ;
26
+
27
+ app . listen ( port , function ( error ) {
28
+ if ( error ) {
29
+ console . error ( error ) ;
30
+ } else {
31
+ console . info (
32
+ 'Listening on port %s. Open up http://localhost:%s/ in your browser.' ,
33
+ port ,
34
+ port
35
+ ) ;
36
+ }
37
+ } ) ;
You can’t perform that action at this time.
0 commit comments