Skip to content

Commit

Permalink
use pretty webpack bar
Browse files Browse the repository at this point in the history
  • Loading branch information
HeskeyBaozi authored and afc163 committed Aug 5, 2018
1 parent 76afe50 commit a0a5641
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"typescript": "~3.0.1",
"unified": "^7.0.0",
"values.js": "^1.0.3",
"webpackbar": "^2.6.1",
"xhr-mock": "^2.4.0",
"xhr2": "^0.1.3"
},
Expand Down
20 changes: 20 additions & 0 deletions site/bisheng.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const path = require('path');
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
const OfflinePlugin = require('@yesmeck/offline-plugin');
const replaceLib = require('antd-tools/lib/replaceLib');
const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const getExternalResources = require('./getExternalResources');

const isDev = process.env.NODE_ENV === 'development';
Expand All @@ -22,6 +24,23 @@ function alertBabelConfig(rules) {
});
}

function usePrettyWebpackBar(config) {
// remove old progress plugin.
config.plugins = config.plugins
.filter((plugin) => {
return !(plugin instanceof webpack.ProgressPlugin)
&& !(plugin instanceof WebpackBar);
});

// use brand new progress bar.
config.plugins.push(
new WebpackBar({
name: '📦 Site',
minimal: false,
})
);
}

module.exports = {
port: 8001,
source: {
Expand Down Expand Up @@ -109,6 +128,7 @@ module.exports = {
}

alertBabelConfig(config.module.rules);
usePrettyWebpackBar(config);

config.plugins.push(
new CSSSplitWebpackPlugin({ size: 4000 }),
Expand Down
19 changes: 19 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This config is for building dist files
const webpack = require('webpack');
const getWebpackConfig = require('antd-tools/lib/getWebpackConfig');
const WebpackBar = require('webpackbar');

// noParse still leave `require('./locale' + name)` in dist files
// ignore is better
Expand Down Expand Up @@ -28,12 +29,30 @@ function externalMoment(config) {
};
}

function usePrettyWebpackBar(config) {
// remove old progress plugin.
config.plugins = config.plugins
.filter((plugin) => {
return !(plugin instanceof webpack.ProgressPlugin)
&& !(plugin instanceof WebpackBar);
});

// use brand new progress bar.
config.plugins.push(
new WebpackBar({
name: '📦 Webpack',
minimal: false,
})
);
}

const webpackConfig = getWebpackConfig(false);
if (process.env.RUN_ENV === 'PRODUCTION') {
webpackConfig.forEach((config) => {
ignoreMomentLocale(config);
externalMoment(config);
addLocales(config);
usePrettyWebpackBar(config);
});
}

Expand Down

0 comments on commit a0a5641

Please sign in to comment.