File tree Expand file tree Collapse file tree 7 files changed +28
-24
lines changed Expand file tree Collapse file tree 7 files changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,15 @@ module.exports = {
11
11
} ,
12
12
type : {
13
13
type : 'list' ,
14
- message : 'Which type do you want?' ,
14
+ message : 'Do you want to use router ?' ,
15
15
choices :[ {
16
- name : 'Single-Page(no react-router)' ,
17
- value : 'single' ,
18
- short : 'Single(No-Router)'
19
- } , {
20
- name : 'Multi-Page(with react-router)' ,
16
+ name : 'With React-Router' ,
21
17
value : 'multi' ,
22
18
short : 'Multi(With-Router)'
19
+ } , {
20
+ name : 'No React-Router' ,
21
+ value : 'single' ,
22
+ short : 'Single(No-Router)'
23
23
} ]
24
24
} ,
25
25
stateContainer :{
@@ -33,7 +33,7 @@ module.exports = {
33
33
eslint : {
34
34
type : 'confirm' ,
35
35
require : true ,
36
- message : 'Use linting with ESLint?' ,
36
+ message : 'lint JS with ESLint?' ,
37
37
default : true
38
38
} ,
39
39
eslintConfig : {
Original file line number Diff line number Diff line change 1
1
const debug = require ( 'debug' ) ( 'app:bin:www' ) ;
2
2
const ip = require ( 'internal-ip' ) ;
3
- const server = require ( '../build/server ' ) ;
3
+ const detect = require ( 'detect-port ' ) ;
4
4
5
- const port = process . env . PORT || 3000 ;
5
+ let port = process . env . PORT || 3000 ;
6
6
const host = ip . v4 ( ) ;
7
7
8
- server . listen ( port , ( err ) => {
9
- if ( err ) throw err ;
10
- debug ( `Server is now running at :
8
+ detect ( port )
9
+ . then ( ( _port ) => {
10
+ if ( port !== _port ) {
11
+ debug ( `Port: ${ port } was occupied, try port: ${ _port } ` ) ;
12
+ port = _port ;
13
+ }
14
+ debug ( `Server will running at :
11
15
=====================================
12
16
Local: http://${ host } :${ port } .
13
17
External: http://localhost:${ port } .
14
18
=====================================` ) ;
15
- } ) ;
19
+ const server = require ( '../build/server' ) ;
20
+ server . listen ( port , ( err ) => {
21
+ if ( err ) throw err ;
22
+ } ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change @@ -5,9 +5,6 @@ const paths = require('./base-config/path');
5
5
6
6
const app = express ( ) ;
7
7
8
- // This rewrites all routes requests to the root /index.html file
9
- app . use ( require ( 'connect-history-api-fallback' ) ( ) ) ;
10
-
11
8
// Apply gzip compression
12
9
app . use ( require ( 'compression' ) ( ) ) ;
13
10
Original file line number Diff line number Diff line change @@ -19,8 +19,7 @@ module.exports = () => {
19
19
loader : 'style-loader'
20
20
} , {
21
21
loader : 'css-loader' ,
22
- // use 'options' for ExtractTextPlugin is not effect, so use 'query' to replace 'options'
23
- query : {
22
+ options : {
24
23
minimize : isProd ,
25
24
sourceMap : ! isProd
26
25
}
@@ -48,7 +47,7 @@ module.exports = () => {
48
47
. forEach ( ( rule ) => {
49
48
const first = rule . use [ 0 ] ;
50
49
const rest = rule . use . slice ( 1 ) ;
51
- rule . loader = ExtractTextPlugin . extract ( { fallbackLoader : first , loader : rest } ) ;
50
+ rule . loader = ExtractTextPlugin . extract ( { fallback : first , loader : rest } ) ;
52
51
delete rule . use ;
53
52
} ) ;
54
53
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ module.exports = (paths) => {
33
33
debug ( 'Enable HMR,noErrors for development(开启开发环境插件)' ) ;
34
34
plugins . push (
35
35
new webpack . HotModuleReplacementPlugin ( ) ,
36
- new webpack . NoErrorsPlugin ( ) // 报错时不退出webpack进程
36
+ new webpack . NoEmitOnErrorsPlugin ( ) // 报错时不退出webpack进程
37
37
) ;
38
38
} else {
39
39
debug ( 'Apply ExtractTextPlugin.(非开发环境开启ExtractTextPlugin)' ) ;
Original file line number Diff line number Diff line change 53
53
"better-npm-run" : " ^0.0.13" ,
54
54
"chalk" : " ^1.1.3" ,
55
55
"compression" : " ^1.6.2" ,
56
- "connect-history-api-fallback" : " ^1.3.0" ,
57
56
"css-loader" : " ^0.26.1" ,
58
57
"debug" : " ^2.4.5" ,
59
58
"eslint" : " ^3.12.2" ,
83
82
"url-loader" : " ^0.5.7" ,
84
83
"webpack" : " ^2.2.1" ,
85
84
"webpack-dev-middleware" : " ^1.8.4" ,
86
- "webpack-hot-middleware" : " ^2.13.2"
85
+ "webpack-hot-middleware" : " ^2.13.2" ,
86
+ "detect-port" : " ^1.1.0"
87
87
},
88
88
"dependencies" : {
89
89
"normalize.css" : " ^5.0.0" ,
Original file line number Diff line number Diff line change 1
1
import React , { Component , PropTypes } from 'react' ;
2
- import { browserHistory , Router } from 'react-router' ;
2
+ import { hashHistory , Router } from 'react-router' ;
3
3
import { Provider } from 'react-redux' ;
4
4
5
5
class App extends Component {
@@ -14,7 +14,7 @@ class App extends Component {
14
14
const { routes, store } = this . props ;
15
15
return (
16
16
< Provider store = { store } >
17
- < Router history = { browserHistory } >
17
+ < Router history = { hashHistory } >
18
18
{ routes }
19
19
</ Router >
20
20
</ Provider >
You can’t perform that action at this time.
0 commit comments