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

The plugin should throw an error, if "from" is empty string #278

Closed
Deliaz opened this issue Jul 26, 2018 · 1 comment
Closed

The plugin should throw an error, if "from" is empty string #278

Deliaz opened this issue Jul 26, 2018 · 1 comment

Comments

@Deliaz
Copy link
Contributor

Deliaz commented Jul 26, 2018

Hey guys.
I spent hours trying to find a reason of weird behavior in my project, but it seems that copy-webpack-plugin takes the content of latest-processed file in case if from is an empty string, and put it inside the "to:" file.
I think in such case the plugin should throw an error or show warning at least.
As I checked in the plugin source, it is related to the wrong path resolving.

Versions:

  • Webpack: 4.16.2
  • copy-webpack-plugin: 4.5.2

Here is the example:
webpack.config.js

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const config = {
	entry: './index.js',

	plugins: [
		new CopyWebpackPlugin([
			{
				from: '',
				to: './test.json'
			}
		]),
	]
};

module.exports = config;

index.js

console.log('Content from index.js');

Webpack run result:

$ ./node_modules/.bin/webpack --mode=development
Hash: 73063a824e1b7c5d19e1
Version: webpack 4.16.2
Time: 1781ms
Built at: 2018-07-26 17:34:11
      Asset      Size  Chunks             Chunk Names
    main.js  3.78 KiB    main  [emitted]  main
./test.json  37 bytes          [emitted]  
Entrypoint main = main.js
[./index.js] 37 bytes {main} [built]

After the build content of test.json will be:

console.log('Content from index.js');
@alexander-akait
Copy link
Member

@Deliaz Thanks for issue

crazko pushed a commit to crazko/kalendario that referenced this issue Feb 20, 2019
## The devDependency [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) was updated from `4.6.0` to `5.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 v5.0.0</summary>

<p><a name="user-content-5.0.0"></a></p>
<h1><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/compare/v4.6.0...v5.0.0">5.0.0</a> (2019-02-20)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>copy only modified files when you use patterns with difference <code>to</code> and same <code>context</code> (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/341" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/341/hovercard">#341</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/e808aa2">e808aa2</a>)</li>
<li>handle <code>[contenthash]</code> as template (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/328" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/328/hovercard">#328</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/61dfe52">61dfe52</a>)</li>
<li>handles when you add new files in watch mode and use <code>glob</code> (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/333" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/333/hovercard">#333</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/49a28f0">49a28f0</a>)</li>
<li>normalize path segment separation, no problems when you mixed <code>/</code> and <code>\\</code> (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/339" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/339/hovercard">#339</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/8f5e638">8f5e638</a>)</li>
<li>throw error if <code>from</code> is an empty string <a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/278" data-hovercard-type="issue" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/issues/278/hovercard">#278</a> (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/285" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/285/hovercard">#285</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/adf1046">adf1046</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li>emit warning instead error if file doesn't exist (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/338" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/338/hovercard">#338</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/a1c5372">a1c5372</a>)</li>
<li>supports copy nested directories/files in symlink (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/issues/335" data-hovercard-type="pull_request" data-hovercard-url="/webpack-contrib/copy-webpack-plugin/pull/335/hovercard">#335</a>) (<a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/f551c0d">f551c0d</a>)</li>
</ul>
<h3>BREAKING CHANGES</h3>
<ul>
<li>drop support for webpack &lt; 4</li>
<li>drop support for node &lt; 6.9</li>
<li><code>debug</code> option was renamed to <code>logLevel</code>, it only accepts string values: <code>trace</code>, <code>debug</code>, <code>info</code>, <code>warn</code>, <code>error</code> and <code>silent</code></li>
<li>plugin emit warning instead error if file doesn't exist</li>
<li>change <code>prototype</code> of plugin, now you can to get correct plugin name</li>
</ul>
</details>

<details>
<summary>Commits</summary>
<p>The new version differs by 26 commits.</p>
<ul>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/517433e3da6cf410dd8930f4d5035b9a6d8cc0dc"><code>517433e</code></a> <code>chore(release): 5.0.0</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/d332212d6421a35c3ef73d9a8cd1464f553a984a"><code>d332212</code></a> <code>test: empty from (#343)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/1f511b85784550788bb33cf8c35e45654fbfaf44"><code>1f511b8</code></a> <code>refactor: debug option (#342)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/e808aa28df31e9815e4e70d3fb9ec2fb45f3949b"><code>e808aa2</code></a> <code>fix: copy only modified files when you use patterns with difference to (#341)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/fbe43cbbf61de05c486607337dec233fef3c2573"><code>fbe43cb</code></a> <code>test: space in directory (#340)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/8f5e63804d47ed91de87c5660bb58654407573ab"><code>8f5e638</code></a> <code>fix: normalize path segment separation (#339)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/a1c537218f19b69c5709b800256b15693592fb28"><code>a1c5372</code></a> <code>feat: emit warning instead error if file doesn't exist (#338)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/f551c0dc1b5b9200564ff79f7c2f3d8de35a620e"><code>f551c0d</code></a> <code>feat: supports copy nested directories/files in symlink (#335)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/2f3ee345f6c11c501a4ba30c8bd46f23ee8fa07a"><code>2f3ee34</code></a> <code>refactor: use <code>Error</code> class for error (#336)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/49a28f07ea7fb235098a472e813ef2f96de4930e"><code>49a28f0</code></a> <code>fix: handles new files when you in watch mode (#333)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/11c9aefe883cf2f5d8d21f57be591489fb50c52c"><code>11c9aef</code></a> <code>refactor: <code>fromArgs</code> option (#332)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/e8706645e13918c6e0ee0b442540ce14a74b04b4"><code>e870664</code></a> <code>refactor: migrate on Set (#331)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/9e1c35e473eb96cb9404b700bc3c25270b1a991a"><code>9e1c35e</code></a> <code>refactor: code (#330)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/ab9439a13ba3a290e262af977dd434e84f7c55a5"><code>ab9439a</code></a> <code>refactor: break compatibility with &lt; webpack 4 (#329)</code></li>
<li><a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/commit/61dfe524c581f3932c9725b990e5675a703124a7"><code>61dfe52</code></a> <code>fix: handle <code>[contenthash]</code> as template (#328)</code></li>
</ul>
<p>There are 26 commits in total.</p>
<p>See the <a href="https://urls.greenkeeper.io/webpack-contrib/copy-webpack-plugin/compare/5cf125e9aa7ff60656c7f826ee8f3b9709059e77...517433e3da6cf410dd8930f4d5035b9a6d8cc0dc">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 🌴
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants