CleanWebpackPlugin in wp-scripts removes built files from previous webpack runs #35980
Labels
[Status] In Progress
Tracking issues with work in progress
[Tool] WP Scripts
/packages/scripts
[Type] Bug
An existing feature does not function as intended
Description
In #23135 @ocean90 introduced the CleanWebpackPlugin plugin for webpack which by default has a feature called
cleanStaleWebpackAssets
that removes all built files from all of the previous webpack runs.In instances where the webpack config exports several configurations as an array:
it causes the webpack run of the second config to remove all the built files from the first run.
Since the CleanWebpackPlugin plugin was added with the intention of removing the built files from entry points with multiple items (per #23134), disabling the
cleanStaleWebpackAssets
feature would still preserve that desired behaviour as it happens during thecleanOnceBeforeBuildPatterns
stage here.Step-by-step reproduction instructions
@wordpress/scripts
package as a dependency for a plugin or theme.webpack.config.js
file to the project root which returns two sets of webpack configs with differentoutput.path
settings.wp-scripts build
and confirm that one of the output paths will sometimes be deleted depending on which webpack config runs first.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: