gajus / write-file-webpack-plugin

Forces webpack-dev-server to write bundle files to the file system.
Other
527 stars 54 forks source link

No way to programatically detect written files #42

Closed nddery closed 6 years ago

nddery commented 7 years ago

Currently there doesn't seem to be any (simple) way to detect which files have been written to disk.

It seems like stats.compilation.assets[].emitted is set to true even for files that haven't changed, so we can't reliably use that.

Instead, I'm relying on the same code this plugin uses to detect if a file has been skipped or not, but that seem unreliable as it relies on being in sync with this plugin and does extra work for nothing.

I'm not sure if this is a viable solution or if there's a better way to accomplish this, but would triggering an event, with the list of written files be something you see as an acceptable solution ? I was thinking something along the lines of calling compiler.applyPlugins('write-file-webpack-plugin-files-written', writtenFiles) after loop through the assets where writtenFiles is an array of the ... written files. We could then hook into the event programatically and do whatever with the files.

If you'd like and see a need for such event, I can submit a PR doing just that.

shellscape commented 6 years ago

Use chokidar and watch the target directory, that'll get you the list of "changed" files.