Skip to content
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

Plugin does not clean output directory in watch mode #80

Closed
realmhamdy opened this issue Mar 30, 2018 · 6 comments
Closed

Plugin does not clean output directory in watch mode #80

realmhamdy opened this issue Mar 30, 2018 · 6 comments

Comments

@realmhamdy
Copy link

realmhamdy commented Mar 30, 2018

Steps to reproduce:

  1. Clone my repo here
  2. npm install
  3. Run webpack --watch in the project dir. The output is generated as expected:
ls -l dist
index.html  main.e4ff9438d89750f15374.js  runtime~main.297929bbe0221ed990a6.js
  1. Modify main.js and save. The output is rebuilt, with 4 files instead of 3:
ls -l dist
index.html                    main.e4ff9438d89750f15374.js
main.64d950fb1144a8614c58.js  runtime~main.297929bbe0221ed990a6.js

If you repeat step 4, you get 5 files, then 6...

Is there something wrong with my build? Isn't this a supported use case?

@octaharon
Copy link

octaharon commented Apr 4, 2018

It's perfectly fine, since watch mode compiles everything to the memory, there's nothing to clear. You can see this behavior is intended here, so there's an option (watch:true) you could try:
https://github.com/johnagan/clean-webpack-plugin/blob/master/index.js#L199

@axefrog
Copy link

axefrog commented Apr 25, 2018

@octaharon Aren't you confusing watch mode with webpack-dev-server? The latter compiles to memory so it can serve changes after recompilation, but regular watch mode is all about regenerating the output folder when files change. Compiling it only to memory would be pointless.

@chrisdothtml
Copy link

chrisdothtml commented Jul 13, 2018

Same problem here. Even if I provide watch: true, it still doesn't work in watch mode

EDIT: Nevermind, I didn't realize the paths provided were relative to the webpack config file and not the CWD (it wasn't clearing for me because I provided the wrong clear path). Providing watch: true works as expected in watch mode.

Not sure why this wouldn't be enabled by default, or why it's even an option in the first place though

@tedbarth
Copy link

It does not feel like a good usability if you have to set { watch = true } first to enable cleaning when files changed while having webpack started with --watch flag. A lot more people will hit the situation we hit here.

I suggest you change the default to watch = true.

@johnagan
Copy link
Owner

Not sure why this wouldn't be enabled by default, or why it's even an option in the first place though

I tend to agree here... Let me see about changing it to default.

crazko pushed a commit to crazko/kalendario that referenced this issue Mar 4, 2019
## The devDependency [clean-webpack-plugin](https://github.com/johnagan/clean-webpack-plugin) was updated from `1.0.1` to `2.0.0`.
This version is **not covered** by your **current version range**.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.

---

<details>
<summary>Release Notes for v2.0.0</summary>

<p><a href="https://urls.greenkeeper.io/chrisblossom/clean-webpack-plugin/blob/2.0/README.md">README.md</a></p>
<p>Changes:</p>
<ul>
<li>No configuration is needed for standard usage (cleans webpack's <code>output.path</code>)</li>
<li>By default during webpack's watch mode, only files created by webpack are removed</li>
<li>Because <a href="https://www.npmjs.com/package/del" rel="nofollow">del</a> is used, globbing is supported</li>
<li>Plugin is tested directly via webpack</li>
<li>All supported versions are tested</li>
<li>Windows is tested via <a href="https://www.appveyor.com/" rel="nofollow">appveyor</a> (no mocked tests)</li>
<li>Complete build system including prepublish hooks and git prepush/commit hooks</li>
<li>Written with Typescript</li>
</ul>
<p>Additional notes:</p>
<ul>
<li>Moved to <a href="https://circleci.com/" rel="nofollow">CircleCI</a> because <a href="https://news.ycombinator.com/item?id=18978251" rel="nofollow">Travis CI was sold</a> and <a href="https://news.ycombinator.com/item?id=19218036" rel="nofollow">looks to now be in maintenance mode</a>.</li>
<li>Replaced Coveralls with <a href="https://codecov.io/" rel="nofollow">codecov</a> because automatic build merging works. This is important because of windows/different webpack version testing</li>
</ul>
<p>Please discuss the current API and suggest any changes.</p>
<p>Closes Issues: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="228815640" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#53" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/53/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/53">#53</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="231858021" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#55" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/55/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/55">#55</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="261623866" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#67" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/67/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/67">#67</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="295742643" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#73" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/73/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/73">#73</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="310004405" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#80" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/80/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/80">#80</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="324754162" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#85" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/85/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/85">#85</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="336239767" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#86" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/86/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/86">#86</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="350539725" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#89" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/89/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/89">#89</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="355469528" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#91" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/91/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/91">#91</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="359168546" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#92" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/92/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/92">#92</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="360576175" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#93" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/93/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/93">#93</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="395851254" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#98" data-hovercard-type="issue" data-hovercard-url="/johnagan/clean-webpack-plugin/issues/98/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/issues/98">#98</a><br>
Closes PRs: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="203192494" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#39" data-hovercard-type="pull_request" data-hovercard-url="/johnagan/clean-webpack-plugin/pull/39/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/pull/39">#39</a> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="296175694" data-permission-text="Issue title is private" data-url="johnagan/clean-webpack-plugin#74" data-hovercard-type="pull_request" data-hovercard-url="/johnagan/clean-webpack-plugin/pull/74/hovercard" href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/pull/74">#74</a></p>
<p>Massive props to <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1595871" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/chrisblossom">@chrisblossom</a> for working on this and pushing it through.</p>
</details>

<details>
<summary>Commits</summary>
<p>The new version differs by 16 commits.</p>
<ul>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/2e7f7f63699460d827329c04779001a237113f57"><code>2e7f7f6</code></a> <code>2.0.0</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/e90a300fdab0f36e671461bb2ccfbd93f288554c"><code>e90a300</code></a> <code>remove unused babel plugins</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/0ff10f0260aaf4dfd20a0a23850a188b64f856a6"><code>0ff10f0</code></a> <code>windows test fixes</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/d6e2e3821fcca8edd9e68ca4cf57198a82e86bb8"><code>d6e2e38</code></a> <code>use *<em>/</em> instead of ** and update packages</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/e19b19d13f5f9f4bc6495afb4d51773dff8d616a"><code>e19b19d</code></a> <code>reorder option types</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/03d12acc097de106d6b218e5954059beae55a04a"><code>03d12ac</code></a> <code>add protectWebpackAssets option</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/f506dc612bb7c9e946f8fa4f1014db7a74a23a67"><code>f506dc6</code></a> <code>add cleanStaleWebpackAssets option</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/c730f4513f80de9192255cdee4ed831d1d94e199"><code>c730f45</code></a> <code>cleanAfterEveryBuildPatterns should not remove webpack assets</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/6d6b34185ab3bc8ce657d7d46023f5311d4ed612"><code>6d6b341</code></a> <code>initialPatterns renamed to cleanOnceBeforeBuildPatterns, customPatterns renamed to cleanAfterEveryBuildPatterns</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/5e5a51914123e35c07ece8f2c8cadaff9f9f39df"><code>5e5a519</code></a> <code>do not include customPatterns in initialPatterns</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/3830778a378b17d26a40c83310a8b4b04a3dfe62"><code>3830778</code></a> <code>use circleci instead of travis</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/bdb5099c7ea65eca177ca5c8c0306338aa39ab1d"><code>bdb5099</code></a> <code>readme updates</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/d2ac5160892d9ebfe2d1056f5d72edd9b3e217e9"><code>d2ac516</code></a> <code>require dangerouslyAllowCleanPatternsOutsideProject to explicitly set dry to false</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/68893e872f716c4e2efc79746bc114aead323748"><code>68893e8</code></a> <code>allowExternal renamed to dangerouslyAllowCleanPatternsOutsideProject</code></li>
<li><a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/commit/816732823b3178420565fac5cb1b2208b5bdb809"><code>8167328</code></a> <code>by default remove all files once prior to compilation, add allowExternal option, migrate dryRun to dry</code></li>
</ul>
<p>There are 16 commits in total.</p>
<p>See the <a href="https://urls.greenkeeper.io/johnagan/clean-webpack-plugin/compare/277811552e04b705b1ad840365eb493a54f6457e...2e7f7f63699460d827329c04779001a237113f57">full diff</a></p>
</details>

<details>
  <summary>FAQ and help</summary>

  There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).
</details>

---


Your [Greenkeeper](https://greenkeeper.io) bot 🌴
@chrisblossom
Copy link
Collaborator

Closed in v2.0.0 via #99. See johnagan/clean-webpack-plugin#usage. Please open a new issue if you continue to have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants