2016-09-20 134 views
0

我使用Webpack Shell Plugin在Webpack构建完成后运行脚本。使用Webpack Shell Plugin时可能发生EventEmitter内存泄漏

然而,当我运行的WebPack我得到这些警告:

(node:91967) Warning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit 
(node:91967) Warning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit 
(node:91967) Warning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit 
(node:91967) Warning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit 
Running onBuildExit 

这是我的插件配置:

config.plugins.push(new WebpackShellPlugin({ 
    onBuildExit: [ 
     "echo 'Running onBuildExit'", 
     "cp file1.js dist/file1.js", 
     "cp file2.js dist/file2.js", 
     "cp file3.js dist/file3.js", 
     "cp file4.js dist/file4.js", 
     "cp file5.js dist/file5.js", 
    ] 
})) 

什么是这些警告的原因以及如何解决这些问题?

回答

0

这并没有解决根本原因,但我的解决方案是将各个命令合并为一个较长的脚本。

config.plugins.push(new WebpackShellPlugin({ 
    onBuildExit: [ 
     ` 
     echo 'Running onBuildExit' 
     cp file1.js dist/file1.js 
     cp file2.js dist/file2.js 
     cp file3.js dist/file3.js 
     cp file4.js dist/file4.js 
     cp file5.js dist/file5.js 
     ` 
    ] 
})) 
相关问题