Closed alexanderdevm closed 5 years ago
Could you provide a minimal reproducible repository?
Sure, I have updated sails-webpack-seed
project with webpack v3 and clean webpack plugin v2 for easy issue reproduction:
Installation:
git clone https://github.com/alexanderdevm/sails_webpack_clean_webpack_plugin_2.git
cd sails_webpack_clean_webpack_plugin_2
npm install sails -g
npm install
sails lift
If everything went well you should see message similar to this:
info: Starting app...
clean-webpack-plugin: removed .tmp
info:
info: .-..-.
info:
info: Sails <| .-..-.
info: v1.1.0 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/path/...`
info: To shut down Sails, press <CTRL> + C at any time.
info: Read more at https://sailsjs.com/support.
debug: -------------------------------------------------------
debug: :: Wed Mar 27 2019 00:03:58 GMT-0400 (DST)
debug: Environment : development
debug: Port : 1337
debug: -------------------------------------------------------
Issue reproduction steps:
While keeping this terminal up, open a new terminal:
vi assets/js/homepage.js
change anything and save.
Look at the previous terminal window.
The issue reproduction is successful when the following message will be appended to console:
clean-webpack-plugin: removed .tmp/public/fonts/.gitkeep
clean-webpack-plugin: removed .tmp/public/images/.gitkeep
The full log will look like this:
info: Starting app...
clean-webpack-plugin: removed .tmp
info:
info: .-..-.
info:
info: Sails <| .-..-.
info: v1.1.0 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/--'
info: `--'-------'
info: ---------------
info: ____---------------_-
info:
info: Server lifted in /path/...
info: To shut down Sails, press
debug: ------------------------------------------------------- debug: :: Wed Mar 27 2019 00:03:58 GMT-0400 (DST)
debug: Environment : development debug: Port : 1337 debug: ------------------------------------------------------- clean-webpack-plugin: removed .tmp/public/fonts/.gitkeep clean-webpack-plugin: removed .tmp/public/images/.gitkeep
Previous behavior:
- clean-webpack-plugin v0.x wiped `.tmp` folder on build ( initial start of the application )
Current behavior:
- clean-webpack-plugin v2.0.1 wipes `.tmp` folder on build and on the first save of files within `assets/` folder.
Expected behaviour:
- clean-webpack-plugin v2.0.1 should only wipe `.tmp` folder on build ( initial start of the application ) only as v0.x did.
Thanks for the repo!
This is happening because copy-webpack-plugin
(see copy-webpack-plugin/pull/360) temporarily adds assets to the webpack asset list.
The code below will fix the issue.
new CleanWebpackPlugin( {
cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, '..', '.tmp')],
cleanAfterEveryBuildPatterns: ['!images/**/*', '!fonts/**/*'],
verbose: true,
dry: false
}),
Thank you, I have apply the suggested fix to the project and the issue is how resolved.
Issue description or question
After updating clean-webpack-plugin to v2 , the
output.path
get cleaned on every save not just once and only during initial build.I have double checked
CleanWebpackPlugin
documentation, still cannot figure out why it deleting my .tmp folder every time I make changes my code.Webpack Config
Environment