Skip to content

Commit 7add556

Browse files
committed
change stats
1 parent 66d5754 commit 7add556

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

bin/compile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
const debug = require('debug')('app:bin:compile');
22
const fs = require('fs-extra');
3+
const chalk = require('chalk');
34
const compiler = require('../build/compiler');
45
const env = require('../build/base-config/environment');
56
const paths = require('../build/base-config/path');
67
const webpackConfig = require('../build/webpack-config');
78

89
const startCompile = () => {
9-
debug(`Start compile with env '${process.env.NODE_ENV}'`);
10+
debug(`Start compile with env '${chalk.green(process.env.NODE_ENV)}'`);
1011
return Promise.resolve()
1112
.then(() => compiler(webpackConfig))
1213
.then((stats) => {
13-
if (stats.hasWarnings() && env.isProd) { // eslint-disable-line
14+
if (stats.hasWarnings() && env.isProd) {
1415
throw new Error('Production not allow warnig, exit .');
1516
}
1617
debug('Copying static assets to dist folder.');

build/base-config/configs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ module.exports = {
1111
performance: {
1212
hints: 'error',
1313
maxEntrypointSize: 1500000
14+
},
15+
stats: {
16+
chunkModules: false,
17+
colors: true,
18+
chunks: false,
19+
children: false
1420
}
1521
},
1622
defaults: {

build/compiler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const webpackCompiler = (webpackConfig) => {
1212
}
1313
const jsonStats = stats.toJson();
1414
if (stats.hasErrors()) {
15-
debug('Webpack compiler with some errors.');
15+
debug('Webpack compile with some errors.');
1616
debug(chalk.red(jsonStats.errors.join('\n')));
1717
return reject(new Error('Webpack compiler with some errors.'));
1818
} else if (stats.hasWarnings()) {
19-
debug('Webpack compiler with some warnings.');
19+
debug('Webpack compile with some warnings.');
2020
debug(chalk.yellow(jsonStats.warnings.join('\n')));
2121
} else {
22-
debug('Webpack compiler no Errors or no Warnings');
22+
debug('Webpack compile no Errors or no Warnings');
2323
}
2424
return resolve(stats);
2525
});

build/server.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ app.use(require('connect-history-api-fallback')());
1111
// Apply gzip compression
1212
app.use(require('compression')());
1313

14-
// ------------------------------------
1514
// Apply Webpack HMR Middleware
16-
// ------------------------------------
1715
if (env.isDev) {
1816
const webpack = require('webpack');
1917
const webpackConfig = require('./webpack-config');
2018
const compiler = webpack(webpackConfig);
21-
debug('Enable webpack dev and HMR middleware(开启开发环境插件 webpack-dev 和 HRM 中间件)');
19+
debug('Apply webpack dev and HMR middleware(开启开发环境插件 webpack-dev 和 HRM 中间件)');
2220
app.use(require('webpack-dev-middleware')(compiler, {
2321
publicPath: webpackConfig.output.publicPath,
2422
contentBase: paths.src(),
2523
lazy: false,
26-
stats: env.config.stats
24+
stats: env.config.stats,
25+
log: debug
26+
}));
27+
app.use(require('webpack-hot-middleware')(compiler, {
28+
heartbeat: 3000,
29+
log: debug
2730
}));
28-
app.use(require('webpack-hot-middleware')(compiler));
2931

3032
app.use(express.static(paths.public()));
3133
} else {

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
"start": "better-npm-run start",
88
"compile": "better-npm-run compile",
99
"lint": "eslint src bin build tests",
10+
"lint:fix": "npm run lint -- --fix",
1011
"start:dist": "better-npm-run start:dist"
1112
},
1213
"keywords": [
1314
"react",
1415
"redux",
15-
"boilerplate"
16+
"boilerplate",
17+
"starkit",
18+
"template"
1619
],
1720
"betterScripts": {
1821
"start": {
@@ -22,7 +25,7 @@
2225
}
2326
},
2427
"compile": {
25-
"command": "npm run lint && node bin/compile",
28+
"command": "rimraf dist/* && npm run lint && node bin/compile",
2629
"env": {
2730
"DEBUG": "app:*:compile*",
2831
"NODE_ENV": "production"
@@ -77,6 +80,7 @@
7780
"postcss-loader": "^1.2.1",
7881
"redbox-react": "^1.3.3",
7982
"redux-logger": "^2.7.4",
83+
"rimraf": "^2.5.4",
8084
"style-loader": "^0.13.1",
8185
"url-loader": "^0.5.7",
8286
"webpack": "2.2.0-rc.3",

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const store = createStore(initialState);
99

1010
// some setup
1111
const MOUNT_NODE = document.getElementById('root');
12+
1213
let render = () => {
1314
const routes = require('./routes/index').default(store); // !important
1415
ReactDOM.render(

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4627,7 +4627,7 @@ right-align@^0.1.1:
46274627
dependencies:
46284628
align-text "^0.1.1"
46294629

4630-
rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@~2.5.1, rimraf@~2.5.4:
4630+
rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.4, rimraf@~2.5.1, rimraf@~2.5.4:
46314631
version "2.5.4"
46324632
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
46334633
dependencies:

0 commit comments

Comments
 (0)