Skip to content

Commit 87b9668

Browse files
committed
Optimize the compilation process.
1 parent 109be06 commit 87b9668

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"eslint-plugin-react": "^7.7.0",
5353
"file-loader": "^1.1.11",
5454
"fs-extra": "^5.0.0",
55-
"gh-pages": "^1.1.0",
55+
"gh-pages": "^1.2.0",
5656
"highlight.js": "^9.12.0",
5757
"html-webpack-plugin": "^3.2.0",
5858
"less": "^3.0.2",
@@ -62,6 +62,7 @@
6262
"optimize-css-assets-webpack-plugin": "^4.0.0",
6363
"postcss-flexbugs-fixes": "^3.2.0",
6464
"postcss-loader": "^2.0.9",
65+
"progress-bar-webpack-plugin": "^1.11.0",
6566
"raw-content-replace-loader": "^1.0.1",
6667
"raw-extend-loader": "^1.0.5",
6768
"raw-tree-replace-loader": "^1.1.0",
@@ -78,8 +79,8 @@
7879
"style-loader": "^0.19.1",
7980
"upath": "^1.0.2",
8081
"url-replace-loader": "^1.0.0",
81-
"webpack": "^4.8.1",
82-
"webpack-cli": "^2.1.3",
82+
"webpack": "^4.10.2",
83+
"webpack-cli": "^3.0.1",
8384
"webpack-dev-middleware": "^3.1.3",
8485
"webpack-dev-server": "^3.1.4",
8586
"webpack-hot-dev-clients": "^1.0.4",

src/build.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
const webpack = require('webpack');
2-
const load = require('loading-cli');
32
const conf = require('./conf/webpack.config.prod');
43
require('colors-cli/toxic');
54

65
module.exports = function serve(program) {
7-
const loading = load('Compiler is running...'.green).start();
8-
loading.color = 'green';
9-
106
const webpackConf = conf(program);
117
const compiler = webpack(webpackConf);
128
compiler.run((err, stats) => {
13-
loading.stop();
149
// 官方输出参数
1510
// https://webpack.js.org/configuration/stats/
1611
// https://github.com/webpack/webpack/issues/538#issuecomment-59586196

src/conf/webpack.config.dev.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = function (cmd) {
2727
loaders.push({
2828
// Process JS with Babel.
2929
test: /\.(js|jsx|mjs)$/,
30-
exclude: paths.getExcludeFoldersRegExp.concat(/\.(cache)/),
30+
// exclude: paths.getExcludeFoldersRegExp.concat(/\.(cache)/),
31+
exclude: /node_modules/,
3132
use: [
3233
{
3334
loader: require.resolve('string-replace-loader'),
@@ -106,7 +107,7 @@ module.exports = function (cmd) {
106107
});
107108

108109
config.plugins = config.plugins.concat([
109-
// new webpack.HotModuleReplacementPlugin(),
110+
new webpack.HotModuleReplacementPlugin(),
110111
new HtmlWebpackPlugin({
111112
inject: true,
112113
favicon: paths.defaultFaviconPath,

src/conf/webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const PATH = require('path');
2+
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
23
const paths = require('./path');
34

45
module.exports = {
@@ -78,7 +79,12 @@ module.exports = {
7879
},
7980
],
8081
},
81-
plugins: [],
82+
plugins: [
83+
new ProgressBarPlugin({
84+
format: ` build [:bar] ${':percent'.green} (:elapsed seconds)`,
85+
clear: false,
86+
}),
87+
],
8288
node: {
8389
dgram: 'empty',
8490
fs: 'empty',

src/server.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const webpack = require('webpack');
22
const WebpackDevServer = require('webpack-dev-server');
33
const opn = require('opn');
44
const detect = require('detect-port');
5-
const load = require('loading-cli');
65
const conf = require('./conf/webpack.config.dev');
76
const createDevServerConfig = require('./conf/webpack.config.server');
87
require('colors-cli/toxic');
@@ -12,13 +11,10 @@ module.exports = function server(cmd) {
1211
let DEFAULT_PORT = cmd.port;
1312
const webpackConf = conf(cmd);
1413
const compiler = webpack(webpackConf);
15-
const loading = load('Compiler is running...'.green).start();
16-
loading.color = 'green';
1714

1815
// https://webpack.js.org/api/compiler-hooks/#aftercompile
1916
// 编译完成之后打印日志
2017
compiler.hooks.done.tap('done', () => {
21-
loading.stop();
2218
// eslint-disable-next-line
2319
console.log(`\nDev Server Listening at ${`http://${HOST}:${DEFAULT_PORT}`.green}`);
2420
});

src/web/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import 'babel-polyfill';
34
import RouterRoot from './Router';
45

56
ReactDOM.render(

0 commit comments

Comments
 (0)