-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CleanWebpackPlugin not removing stale assets in dist folder #2319
Comments
hi @sacr3dc0w , thanks. are you going to create PR for this? |
After making changes to our .js files, we noticed the changes were not being reflected in localhost or being pushed to our live site. We removed line 61 from webpack.common.js, and this did not fix the issue even n after a stencil bundle. Is there anything else we need to do to resolve this? |
Steps on what to do after deleting line 61 would be much appreciated! Simply deleting the line isn't allowing for changes to js files to appear in local. |
Upon further inspection and testing we discovered the following. We removed cleanOnceBeforeBuildPatterns: ['assets/dist'], and then removed our node_modules and dist folders. Upon runing npm install with this line now removed, when you stencil start, dist is not automatically created, after running stencil bundle dist is created. In order for js file changes to reflect you need to run stencil bundle again to see your changes and then start back up localhost. The root of the problem seems to be that Webpack Bundle Analyzer does not trigger on stencil start or on saving of a js file, so dist never gets updated causing the js to reflect as well. Is there going to be a further fix than just removing that line to get the functionality back similar to 6.7.0? Starting and stopping localhost to bundle is not ideal. |
We can consider removing clean-webpack-plugin and use |
The code for our stores runs a lot of custom JavaScript and theme modifications. Since the 6.8.0 release (more specifically #2311), we were getting the TR-302 / 2500+ files, which meant pushing updates halted. We initially found a solution: delete assets/dist and node_modules, then reinstall and push the theme. I began to wonder why that was the solution, and if the assets/dist folder wasn't pruning stale files from between development and productions. Upon further investigation, I discovered the potential problem and have a possible solution.
Expected behavior
CleanWebpackPlugin removes files in the output.path directory and outputs new ones.
Actual behavior
New files are generated, but the old ones remain.
Steps to reproduce the behavior
Make sure Cornerstone is up-to-date (6.8.0)
Run
stencil start
, close that instance, then runstencil bundle
.User Notes / Suggested Solution
I believe this is due to the
cleanOnceBeforeBuildPatterns
setting:cornerstone/webpack.common.js
Line 61 in e400137
Unless I'm misunderstanding, that setting doesn't appear to be necessary. From johnagan/clean-webpack-plugin#106
All files inside webpack's output.path directory will be removed, but the directory itself will not be.
Below is an output from assets/dist with the settings as they are currently after I run
stencil start
. Looks normal. Scroll below to see the list of whenstencil bundle
is run after killing the local instance.BEFORE
AFTER
Now if we remove line 61 entirely, stale files are removed.
cornerstone/webpack.common.js
Line 61 in e400137
BEFORE
AFTER
The text was updated successfully, but these errors were encountered: