@@ -5,6 +5,9 @@ var webpackDevMiddleware = require("webpack-dev-middleware");
5
5
var webpack = require ( "webpack" ) ;
6
6
var SingleEntryDependency = require ( "webpack/lib/dependencies/SingleEntryDependency" ) ;
7
7
8
+ var blocked = [ ]
9
+ var isBlocked = false
10
+
8
11
function Plugin (
9
12
webpackOptions , /* config.webpack */
10
13
webpackServerOptions , /* config.webpackServer */
@@ -61,6 +64,10 @@ function Plugin(
61
64
compiler . plugin ( "make" , this . make . bind ( this ) ) ;
62
65
} , this ) ;
63
66
67
+ compiler . plugin ( "compile" , function ( ) {
68
+ isBlocked = true
69
+ } )
70
+
64
71
compiler . plugin ( "done" , function ( stats ) {
65
72
var applyStats = Array . isArray ( stats . stats ) ? stats . stats : [ stats ] ;
66
73
var assets = [ ] ;
@@ -84,6 +91,12 @@ function Plugin(
84
91
cb ( ) ;
85
92
} ) ;
86
93
}
94
+
95
+ isBlocked = false
96
+ for ( var i = 0 ; i < blocked . length ; i ++ ) {
97
+ blocked [ i ] ( ) ;
98
+ }
99
+ blocked = [ ]
87
100
} . bind ( this ) ) ;
88
101
compiler . plugin ( "invalid" , function ( ) {
89
102
if ( ! this . waiting ) this . waiting = [ ] ;
@@ -188,7 +201,18 @@ function createPreprocesor( /* config.basePath */ basePath, webpackPlugin) {
188
201
} ;
189
202
}
190
203
204
+ function createWebpackBlocker ( ) {
205
+ return function ( request , response , next ) {
206
+ if ( isBlocked ) {
207
+ blocked . push ( next )
208
+ } else {
209
+ next ( )
210
+ }
211
+ }
212
+ }
213
+
191
214
module . exports = {
192
215
"webpackPlugin" : [ "type" , Plugin ] ,
193
- "preprocessor:webpack" : [ "factory" , createPreprocesor ]
216
+ "preprocessor:webpack" : [ "factory" , createPreprocesor ] ,
217
+ "middleware:webpackBlocker" : [ "factory" , createWebpackBlocker ]
194
218
} ;
0 commit comments