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 cleaning after bundle is built #67

Closed
mriede opened this issue Sep 29, 2017 · 10 comments
Closed

Plugin cleaning after bundle is built #67

mriede opened this issue Sep 29, 2017 · 10 comments

Comments

@mriede
Copy link

mriede commented Sep 29, 2017

Hi!

I'm using this in combination with django-webpack-loader, and often times (especially if I accidentally save two times in a row) the plugin removes the bundle after it was compiled. Which leaves me with a blank page. Any idea on how to fix that?

@alexreg
Copy link

alexreg commented Oct 1, 2017

This is a problem for me too! I'm using it with webpack-dev-server instead, though.

@a-siewe
Copy link

a-siewe commented Oct 5, 2017

I have the same issue

@SirNeuman
Copy link

SirNeuman commented Nov 10, 2017

Happens to me to. More often than not it works normally, but it does sometimes clean the folder after the bundle is built. I'm just using babel-loader.

@jackypan1989
Copy link

https://github.com/jackypan1989/del-webpack-plugin

@Clay-Ferguson
Copy link

I see same issue. This plugin deletes my 'dist' folder AFTER the build is done, making it a bit counterproductive. haha.

@ChrisRAoW
Copy link
Contributor

I submitted a pull request last week which is already merged. You can now set "beforeEmit" to true in the options and it will clean the dist folder just before the files are emitted to the output dir

@fleurdulicoder
Copy link

So, I am using "beforeEmit" set to true.

plugins: [ new CleanWebpackPlugin(['*'], { root: path.join(__dirname, 'dist/'), beforeEmit: true, }), ... ]

That creates a totally new issue in itself. When I load webpack server, apparently, this plugin just before I load my web page, deletes my dist/ folder... as you said, beforeEmit... here is my configuration for the command in package.json

"scripts": {
    "build": "webpack --mode production",
    "start": "webpack-dev-server --mode production --open --content-base dist/",
    ...
}

Any ideas how not to delete the dist/ upon launching the webpack-dev-server?

Thanks,
Ella

@ChrisRAoW
Copy link
Contributor

@flurdulis I would not suggest to use this option in development. Just for production environments.

@meglio
Copy link

meglio commented Nov 16, 2018

I can confirm that the plugin referenced by @jackypan1989 's above just solved my "-w" problem.

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

10 participants