Skip to content

Commit 16778c4

Browse files
committed
some config change
1 parent 7e872b5 commit 16778c4

File tree

7 files changed

+28
-24
lines changed

7 files changed

+28
-24
lines changed

meta.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ module.exports = {
1111
},
1212
type: {
1313
type: 'list',
14-
message: 'Which type do you want?',
14+
message: 'Do you want to use router?',
1515
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',
2117
value: 'multi',
2218
short: 'Multi(With-Router)'
19+
},{
20+
name: 'No React-Router',
21+
value: 'single',
22+
short: 'Single(No-Router)'
2323
}]
2424
},
2525
stateContainer:{
@@ -33,7 +33,7 @@ module.exports = {
3333
eslint: {
3434
type: 'confirm',
3535
require: true,
36-
message: 'Use linting with ESLint?',
36+
message: 'lint JS with ESLint?',
3737
default: true
3838
},
3939
eslintConfig: {

template/bin/www.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
const debug = require('debug')('app:bin:www');
22
const ip = require('internal-ip');
3-
const server = require('../build/server');
3+
const detect = require('detect-port');
44

5-
const port = process.env.PORT || 3000;
5+
let port = process.env.PORT || 3000;
66
const host = ip.v4();
77

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 :
1115
=====================================
1216
Local: http://${host}:${port}.
1317
External: http://localhost:${port}.
1418
=====================================`);
15-
});
19+
const server = require('../build/server');
20+
server.listen(port, (err) => {
21+
if (err) throw err;
22+
});
23+
});

template/build/server.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const paths = require('./base-config/path');
55

66
const app = express();
77

8-
// This rewrites all routes requests to the root /index.html file
9-
app.use(require('connect-history-api-fallback')());
10-
118
// Apply gzip compression
129
app.use(require('compression')());
1310

template/build/webpack-config/loaders.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ module.exports = () => {
1919
loader: 'style-loader'
2020
}, {
2121
loader: 'css-loader',
22-
// use 'options' for ExtractTextPlugin is not effect, so use 'query' to replace 'options'
23-
query: {
22+
options: {
2423
minimize: isProd,
2524
sourceMap: !isProd
2625
}
@@ -48,7 +47,7 @@ module.exports = () => {
4847
.forEach((rule) => {
4948
const first = rule.use[0];
5049
const rest = rule.use.slice(1);
51-
rule.loader = ExtractTextPlugin.extract({ fallbackLoader: first, loader: rest });
50+
rule.loader = ExtractTextPlugin.extract({ fallback: first, loader: rest });
5251
delete rule.use;
5352
});
5453
}

template/build/webpack-config/plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = (paths) => {
3333
debug('Enable HMR,noErrors for development(开启开发环境插件)');
3434
plugins.push(
3535
new webpack.HotModuleReplacementPlugin(),
36-
new webpack.NoErrorsPlugin() // 报错时不退出webpack进程
36+
new webpack.NoEmitOnErrorsPlugin() // 报错时不退出webpack进程
3737
);
3838
} else {
3939
debug('Apply ExtractTextPlugin.(非开发环境开启ExtractTextPlugin)');

template/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"better-npm-run": "^0.0.13",
5454
"chalk": "^1.1.3",
5555
"compression": "^1.6.2",
56-
"connect-history-api-fallback": "^1.3.0",
5756
"css-loader": "^0.26.1",
5857
"debug": "^2.4.5",
5958
"eslint": "^3.12.2",
@@ -83,7 +82,8 @@
8382
"url-loader": "^0.5.7",
8483
"webpack": "^2.2.1",
8584
"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"
8787
},
8888
"dependencies": {
8989
"normalize.css": "^5.0.0",

template/src/containers/AppContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
2-
import { browserHistory, Router } from 'react-router';
2+
import { hashHistory, Router } from 'react-router';
33
import { Provider } from 'react-redux';
44

55
class App extends Component {
@@ -14,7 +14,7 @@ class App extends Component {
1414
const { routes, store } = this.props;
1515
return (
1616
<Provider store={store}>
17-
<Router history={browserHistory} >
17+
<Router history={hashHistory} >
1818
{routes}
1919
</Router>
2020
</Provider>

0 commit comments

Comments
 (0)