Skip to content

Commit 32ff29e

Browse files
committed
1.9.5
1 parent 79d9857 commit 32ff29e

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

.dawn/pipe.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ build:
1919
cssModules: false
2020
compress: false
2121
stats: true
22-
presetEnv: false
2322

2423
test:
2524
- name: lint

lib/generate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ async function handlerPlugins(wpConfig, opts) {
220220
filename: './report/stats.html'
221221
}));
222222
}
223+
if (opts.optimizationBailout) {
224+
wpConfig.plugins.push(new webpack.optimize.ModuleConcatenationPlugin({
225+
optimizationBailout: true
226+
}));
227+
}
223228
if (!opts.watch) {
224229
if (opts.env) {
225230
wpConfig.plugins.push(new webpack.DefinePlugin({

lib/index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,30 @@ module.exports = function (opts) {
6767

6868
await this.utils.sleep(1000);
6969

70+
function printStats(json) {
71+
if (!opts.optimizationBailout) return;
72+
json.modules.forEach(item => {
73+
if (!item.optimizationBailout ||
74+
item.optimizationBailout.length < 1) {
75+
return;
76+
}
77+
this.console.log(item.name);
78+
item.optimizationBailout.
79+
forEach(msg => this.console.warn(` ${msg}`));
80+
});
81+
}
82+
7083
//build
7184
let compiler = webpack(config);
7285
if (opts.watch) {
7386
compiler.watch(opts.watchOpts, (err, stats) => {
7487
if (err) return this.console.error(err);
88+
let json = stats.toJson();
7589
if (stats.hasErrors()) {
76-
let json = stats.toJson();
7790
this.console.error(json.errors.join(os.EOL + os.EOL));
7891
}
92+
if (this.emit) this.emit('webpack.stats', stats);
93+
printStats(json);
7994
this.console.log('实时编译:', Date.now());
8095
next();
8196
});
@@ -86,14 +101,18 @@ module.exports = function (opts) {
86101
if (stats.hasErrors()) {
87102
return this.console.error(json.errors.join(os.EOL + os.EOL));
88103
}
104+
if (this.emit) this.emit('webpack.stats', stats);
89105
this.console.log('');
90106
utils.each(json.assetsByChunkName, (chunkName, assets) => {
91107
this.console.info(`Chunk: ${chunkName}`);
92108
if (utils.isArray(assets)) {
93-
this.console.log(assets.map(name => ` file: ${name}`).join(os.EOL));
109+
this.console.log(
110+
assets.map(name => ` file: ${name}`).join(os.EOL)
111+
);
94112
}
95113
this.console.log('');
96114
});
115+
printStats(json);
97116
this.console.info('完成');
98117
next();
99118
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dn-middleware-webpack",
3-
"version": "1.9.3",
3+
"version": "1.9.5",
44
"description": "",
55
"main": "./lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)