File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed
Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 11var path = require ( 'path' ) ;
22var fse = require ( 'fs-extra' ) ;
33var _ = require ( 'lodash' ) ;
4+ var mutexify = require ( 'mutexify' ) ;
5+
6+ var lock = mutexify ( ) ;
47
58function ManifestPlugin ( opts ) {
69 this . opts = _ . assign ( {
@@ -142,23 +145,23 @@ ManifestPlugin.prototype.apply = function(compiler) {
142145
143146 var json = JSON . stringify ( manifest , null , 2 ) ;
144147
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 ) ;
153150
154151 if ( this . opts . writeToFileEmit ) {
155- var outputFolder = compilation . options . output . path ;
156- var outputFile = path . join ( outputFolder , this . opts . fileName ) ;
157-
158152 fse . outputFileSync ( outputFile , json ) ;
159153 }
160154
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+ } ) ;
162165 } . bind ( this ) ) ;
163166} ;
164167
Original file line number Diff line number Diff line change 4040 "homepage" : " https://github.com/danethurber/webpack-manifest-plugin" ,
4141 "dependencies" : {
4242 "fs-extra" : " ^0.30.0" ,
43- "lodash" : " >=3.5 <5"
43+ "lodash" : " >=3.5 <5" ,
44+ "mutexify" : " ^1.1.0"
4445 },
4546 "nyc" : {
4647 "reporter" : [
You can’t perform that action at this time.
0 commit comments