File tree 3 files changed +11
-6
lines changed
3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ const noop = () => {};
100
100
* @template {IncomingMessage} [RequestInternal = IncomingMessage]
101
101
* @template {ServerResponse} [ResponseInternal = ServerResponse]
102
102
* @typedef {Object } Options
103
- * @property {boolean | ((targetPath: string) => boolean) } [writeToDisk]
103
+ * @property {boolean | ((targetPath: string, compilationName?: string ) => boolean) } [writeToDisk]
104
104
* @property {NonNullable<Configuration["output"]>["publicPath"] } [publicPath]
105
105
* @property {boolean | string } [index]
106
106
* @property {boolean } [lastModified]
Original file line number Diff line number Diff line change @@ -29,11 +29,13 @@ function setupWriteToDisk(context) {
29
29
30
30
compiler . hooks . assetEmitted . tapAsync (
31
31
"DevMiddleware" ,
32
- ( file , info , callback ) => {
33
- const { targetPath, content } = info ;
32
+ ( _file , info , callback ) => {
33
+ const { targetPath, content, compilation } = info ;
34
34
const { writeToDisk : filter } = context . options ;
35
35
const allowWrite =
36
- filter && typeof filter === "function" ? filter ( targetPath ) : true ;
36
+ filter && typeof filter === "function"
37
+ ? filter ( targetPath , compilation . name )
38
+ : true ;
37
39
38
40
if ( ! allowWrite ) {
39
41
return callback ( ) ;
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export = wdm;
75
75
* @template {IncomingMessage} [RequestInternal = IncomingMessage]
76
76
* @template {ServerResponse} [ResponseInternal = ServerResponse]
77
77
* @typedef {Object } Options
78
- * @property {boolean | ((targetPath: string) => boolean) } [writeToDisk]
78
+ * @property {boolean | ((targetPath: string, compilationName?: string ) => boolean) } [writeToDisk]
79
79
* @property {NonNullable<Configuration["output"]>["publicPath"] } [publicPath]
80
80
* @property {boolean | string } [index]
81
81
* @property {boolean } [lastModified]
@@ -256,7 +256,10 @@ type Options<
256
256
RequestInternal extends IncomingMessage = import ( "http" ) . IncomingMessage ,
257
257
ResponseInternal extends ServerResponse = ServerResponse ,
258
258
> = {
259
- writeToDisk ?: boolean | ( ( targetPath : string ) => boolean ) | undefined ;
259
+ writeToDisk ?:
260
+ | boolean
261
+ | ( ( targetPath : string , compilationName ?: string ) => boolean )
262
+ | undefined ;
260
263
publicPath ?: NonNullable < Configuration [ "output" ] > [ "publicPath" ] ;
261
264
index ?: string | boolean | undefined ;
262
265
lastModified ?: boolean | undefined ;
You can’t perform that action at this time.
0 commit comments