File tree 6 files changed +89
-6
lines changed
6 files changed +89
-6
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- webpack : function ( config ) {
2
+ webpack : function ( config , { dev } ) {
3
+ // For the development version, we'll use React.
4
+ // Because, it support react hot loading and so on.
5
+ if ( dev ) {
6
+ return config
7
+ }
8
+
3
9
config . resolve . alias = {
4
10
'react' : 'inferno-compat' ,
5
11
'react-dom' : 'inferno-compat'
Original file line number Diff line number Diff line change 2
2
"name" : " using-inferno" ,
3
3
"version" : " 1.0.0" ,
4
4
"scripts" : {
5
- "dev" : " next " ,
5
+ "dev" : " node server.js " ,
6
6
"build" : " next build" ,
7
- "start" : " next start "
7
+ "start" : " NODE_ENV=production node server.js "
8
8
},
9
9
"dependencies" : {
10
10
"inferno" : " ^1.0.7" ,
11
11
"inferno-compat" : " ^1.0.7" ,
12
+ "inferno-server" : " ^1.3.0-rc.9" ,
13
+ "module-alias" : " ^2.0.0" ,
12
14
"next" : " ^2.0.0-beta" ,
13
15
"react" : " ^15.4.2" ,
14
16
"react-dom" : " ^15.4.2"
Original file line number Diff line number Diff line change
1
+ const dev = process . env . NODE_ENV !== 'production'
2
+ const moduleAlias = require ( 'module-alias' )
3
+
4
+ // For the development version, we'll use React.
5
+ // Because, it support react hot loading and so on.
6
+ if ( ! dev ) {
7
+ moduleAlias . addAlias ( 'react' , 'inferno-compat' )
8
+ moduleAlias . addAlias ( 'react-dom/server' , 'inferno-server' )
9
+ moduleAlias . addAlias ( 'react-dom' , 'inferno-compat' )
10
+ }
11
+
12
+ const { createServer } = require ( 'http' )
13
+ const { parse } = require ( 'url' )
14
+ const next = require ( 'next' )
15
+
16
+ const app = next ( { dev } )
17
+ const handle = app . getRequestHandler ( )
18
+
19
+ app . prepare ( )
20
+ . then ( ( ) => {
21
+ createServer ( ( req , res ) => {
22
+ const parsedUrl = parse ( req . url , true )
23
+ handle ( req , res , parsedUrl )
24
+ } )
25
+ . listen ( 3000 , ( err ) => {
26
+ if ( err ) throw err
27
+ console . log ( '> Ready on http://localhost:3000' )
28
+ } )
29
+ } )
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- webpack : function ( config ) {
2
+ webpack : function ( config , { dev } ) {
3
+ // For the development version, we'll use React.
4
+ // Because, it support react hot loading and so on.
5
+ if ( dev ) {
6
+ return config
7
+ }
8
+
3
9
config . resolve . alias = {
4
10
'react' : 'preact-compat/dist/preact-compat' ,
5
11
'react-dom' : 'preact-compat/dist/preact-compat'
6
12
}
13
+
14
+ // Disable uglify. This has been fixed in https://github.com/developit/preact-compat/issues/155.
15
+ // Can be removed once there is a new preact-compat release.
16
+ config . plugins = config . plugins . filter ( ( plugin ) => {
17
+ if ( plugin . constructor . name === 'UglifyJsPlugin' ) {
18
+ return false
19
+ } else {
20
+ return true
21
+ }
22
+ } )
23
+
7
24
return config
8
25
}
9
26
}
Original file line number Diff line number Diff line change 2
2
"name" : " hello-world" ,
3
3
"version" : " 1.0.0" ,
4
4
"scripts" : {
5
- "dev" : " next " ,
5
+ "dev" : " node server.js " ,
6
6
"build" : " next build" ,
7
- "start" : " next start "
7
+ "start" : " NODE_ENV=production node server.js "
8
8
},
9
9
"dependencies" : {
10
+ "module-alias" : " ^2.0.0" ,
10
11
"next" : " ^2.0.0-beta" ,
11
12
"preact" : " ^7.1.0" ,
12
13
"preact-compat" : " ^3.9.4" ,
Original file line number Diff line number Diff line change
1
+ const dev = process . env . NODE_ENV !== 'production'
2
+ const moduleAlias = require ( 'module-alias' )
3
+
4
+ // For the development version, we'll use React.
5
+ // Because, it support react hot loading and so on.
6
+ if ( dev ) {
7
+ moduleAlias . addAlias ( 'react' , 'preact-compat' )
8
+ moduleAlias . addAlias ( 'react-dom' , 'preact-compat' )
9
+ }
10
+
11
+ const { createServer } = require ( 'http' )
12
+ const { parse } = require ( 'url' )
13
+ const next = require ( 'next' )
14
+
15
+ const app = next ( { dev } )
16
+ const handle = app . getRequestHandler ( )
17
+
18
+ app . prepare ( )
19
+ . then ( ( ) => {
20
+ createServer ( ( req , res ) => {
21
+ const parsedUrl = parse ( req . url , true )
22
+ handle ( req , res , parsedUrl )
23
+ } )
24
+ . listen ( 3000 , ( err ) => {
25
+ if ( err ) throw err
26
+ console . log ( '> Ready on http://localhost:3000' )
27
+ } )
28
+ } )
You can’t perform that action at this time.
0 commit comments