Webpack Plugin: run command after assets are written to file system

Do you want to request a feature or report a bug?

This is a Bug

What is the current behavior?

I created a very basic Plugin like

 Testplugin.prototype.apply = function(compiler) {

    compiler.plugin('after-emit', function(compilation, callback) {
        console.log("Files Emiited")

Now in the first comilation process, the “after-emit” event is fired before my bundled files are written to the filesystem. This will cause, that my task to move the files to another location, doesn´t get all files.

What is the expected behavior?

I would expect that the event is thrown when all my compiled files exists on the filesystem.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

  • I´m running in the webpack watch mode
  • The failure only occurs on the first comilation. After the first comilation, when webpack doesn´t create all files over new, they are already adjusted when the “after-emit” event hook is thrown.
  • I also tested it with the “done” event –> same result
  • I´m using Webpack 3.5.5, but already tested it with 3.10.0 with the same result
  • Node Version: 6.10.2
  • There is already an existing stackoverflow article without any response


new WebpackShellPlugin({onBuildStart:['echo "Webpack Start"'], onBuildEnd:['echo "Webpack End"']})

“Webpack End” is printed out before all files are in the output folder

Author: Fantashit

2 thoughts on “Webpack Plugin: run command after assets are written to file system

  1. This is a big pain for SSR where you want to build the client files, emit a stats.json file, and then consume that stats.json file in a server webpack configuration — the stats.json file from the client build is often not available on disk before the server build needs it.

  2. does anyone still face this issue? Generating a file in assets folder after assets is completed seems impossible yet.

Comments are closed.