File tree 2 files changed +17
-13
lines changed
2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 1
1
var path = require ( 'path' ) ;
2
2
var fse = require ( 'fs-extra' ) ;
3
3
var _ = require ( 'lodash' ) ;
4
+ var mutexify = require ( 'mutexify' ) ;
5
+
6
+ var lock = mutexify ( ) ;
4
7
5
8
function ManifestPlugin ( opts ) {
6
9
this . opts = _ . assign ( {
@@ -142,23 +145,23 @@ ManifestPlugin.prototype.apply = function(compiler) {
142
145
143
146
var json = JSON . stringify ( manifest , null , 2 ) ;
144
147
145
- compilation . assets [ outputName ] = {
146
- source : function ( ) {
147
- return json ;
148
- } ,
149
- size : function ( ) {
150
- return json . length ;
151
- }
152
- } ;
148
+ var outputFolder = compilation . options . output . path ;
149
+ var outputFile = path . resolve ( compilation . options . output . path , this . opts . fileName ) ;
153
150
154
151
if ( this . opts . writeToFileEmit ) {
155
- var outputFolder = compilation . options . output . path ;
156
- var outputFile = path . join ( outputFolder , this . opts . fileName ) ;
157
-
158
152
fse . outputFileSync ( outputFile , json ) ;
159
153
}
160
154
161
- compileCallback ( ) ;
155
+ compiler . outputFileSystem . mkdirp ( path . dirname ( outputFile ) , function ( err ) {
156
+ if ( err ) return compileCallback ( err ) ;
157
+
158
+ lock ( function ( release ) {
159
+ compiler . outputFileSystem . writeFile ( outputFile , json , function ( err ) {
160
+ release ( ) ;
161
+ compileCallback ( err ) ;
162
+ } ) ;
163
+ } ) ;
164
+ } ) ;
162
165
} . bind ( this ) ) ;
163
166
} ;
164
167
Original file line number Diff line number Diff line change 40
40
"homepage" : " https://github.com/danethurber/webpack-manifest-plugin" ,
41
41
"dependencies" : {
42
42
"fs-extra" : " ^0.30.0" ,
43
- "lodash" : " >=3.5 <5"
43
+ "lodash" : " >=3.5 <5" ,
44
+ "mutexify" : " ^1.1.0"
44
45
},
45
46
"nyc" : {
46
47
"reporter" : [
You can’t perform that action at this time.
0 commit comments