This repository was archived by the owner on May 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +33
-8
lines changed Expand file tree Collapse file tree 4 files changed +33
-8
lines changed Original file line number Diff line number Diff line change
1
+ const { PORT , NODE_ENV } = process . env
2
+
3
+ const APP_CONFIG = {
4
+ shared : {
5
+
6
+ } ,
7
+
8
+ development : {
9
+ PORT : parseInt ( PORT , 10 ) || 3000
10
+ } ,
11
+
12
+ production : {
13
+ PORT : parseInt ( PORT , 10 ) || 3010
14
+ }
15
+ }
16
+
17
+ // default to development config
18
+ export default {
19
+ ...APP_CONFIG . shared ,
20
+ ...( APP_CONFIG [ NODE_ENV ] || APP_CONFIG . development )
21
+ }
Original file line number Diff line number Diff line change @@ -4,14 +4,16 @@ import Koa from 'koa'
4
4
import convert from 'koa-convert'
5
5
import webpack from 'webpack'
6
6
7
+ import { PORT } from '../../core/config'
8
+
7
9
export default ( ) => {
8
10
const webpackServer = new Koa ( )
9
11
const compiler = webpack ( require ( '../../webpack.config.babel' ) )
10
12
11
13
const config = {
12
- port : 3001 ,
14
+ port : PORT + 1 ,
13
15
options : {
14
- publicPath : ' http://localhost:3001 /assets/' ,
16
+ publicPath : ` http://localhost:${ PORT + 1 } /assets/` ,
15
17
hot : true ,
16
18
stats : {
17
19
assets : true ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import staticCache from 'koa-static-cache'
8
8
9
9
import createStore from 'app/store'
10
10
import render from 'core/universal-render'
11
+ import { PORT } from 'core/config'
11
12
12
13
const { NODE_ENV } = process . env
13
14
@@ -16,7 +17,7 @@ const app = new Koa()
16
17
// Proxy asset folder to webpack development server in development mode
17
18
if ( NODE_ENV === 'development' ) {
18
19
const proxy = require ( 'koa-proxy' ) ( {
19
- host : ' http://0.0.0.0:3001' ,
20
+ host : ` http://0.0.0.0:${ PORT + 1 } ` ,
20
21
map : ( filePath ) => `assets/${ filePath } `
21
22
} )
22
23
app . use ( convert ( mount ( '/assets' , proxy ) ) )
@@ -52,8 +53,8 @@ app.use(async (ctx) => {
52
53
}
53
54
} )
54
55
55
- app . listen ( 3000 )
56
+ app . listen ( PORT )
56
57
57
58
// Tell parent process koa-server is started
58
59
if ( process . send ) process . send ( 'online' )
59
- debug ( 'koa' ) ( 'Application started on port 3000' )
60
+ debug ( 'koa' ) ( '`koa-render-server` started on port %s' , PORT )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import webpack from 'webpack'
4
4
import BrowserSyncPlugin from 'browser-sync-webpack-plugin'
5
5
6
6
import writeStats from './run/utils/write-stats'
7
+ import { PORT } from './core/config'
7
8
8
9
import {
9
10
JS_REGEX ,
@@ -22,7 +23,7 @@ export default {
22
23
app : [
23
24
'babel-polyfill' ,
24
25
'react-hot-loader/patch' ,
25
- ' webpack-hot-middleware/client?path=http://localhost:3001 /__webpack_hmr' ,
26
+ ` webpack-hot-middleware/client?path=http://localhost:${ PORT + 1 } /__webpack_hmr` ,
26
27
resolve ( './app' )
27
28
]
28
29
} ,
@@ -49,8 +50,8 @@ export default {
49
50
plugins : [
50
51
new BrowserSyncPlugin ( {
51
52
host : 'localhost' ,
52
- port : 3002 ,
53
- proxy : ' 0.0.0.0:3000'
53
+ port : PORT + 2 ,
54
+ proxy : ` 0.0.0.0:${ PORT } `
54
55
} , { reload : false } ) ,
55
56
56
57
new webpack . HotModuleReplacementPlugin ( ) ,
You can’t perform that action at this time.
0 commit comments