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

Ignore file that does not exist #126

Closed
matheus1lva opened this issue May 4, 2017 · 12 comments · Fixed by #338
Closed

Ignore file that does not exist #126

matheus1lva opened this issue May 4, 2017 · 12 comments · Fixed by #338

Comments

@matheus1lva
Copy link

Hello, is there a way to ignore the files that does not exist instead of throwing errors?

@hellivan
Copy link

hellivan commented May 8, 2017

As far as I remember, webpack 1.x version of copy-webpack-plugin ignored non-existing files, didn't it? Anyways, having a flag for such a behavior would be great.

@matheus1lva
Copy link
Author

@hellivan i'm using 2.x so i'm not aware of that. Indeed, a flag to not throw errors and stop the bundling would be really nice!

@singuerinc
Copy link

@playma256 If you use the context property you don't get any error if the folder/file doesn't exist.

{ context: path.resolve(__dirname, "a", "b"), from: "**/*", to: "c" }

@derekdon
Copy link

derekdon commented Sep 4, 2017

I don't suppose it's possible to do this when you're not using globs?

{ from: 'a' },
{ from: 'b/c', to: 'c' },
{ from: 'd' }

I'd like to just get a warning when a specific "from" file doesn't exist, not break the build.

@utajum
Copy link

utajum commented Sep 12, 2017

I'm looking into this as a workaround for https://github.com/webpack/webpack/issues/5360

@alexander-akait
Copy link
Member

@michael-ciniawsky what do you think about this option?

@michael-ciniawsky
Copy link
Member

hmm... imho it's simply an {Error} (ENOENT) 😛. But if this is common in build chains (CI) to sneak in for some reason we can consider to relax it into a warning. But e.g sole 'misconfiguration' (adding patterns for non-existent files) isn't enough to justify changing the current behavior tbh.

@zanettin
Copy link

would be nice to have an option like this or just another debug option ignore or silent. we run several apps through the same webpack config and have to include the plugin conditionally now. thanks for all your work on that plugin 💪

@clm2609
Copy link

clm2609 commented Aug 3, 2018

Im having the same issue as @zanettin , would love the option to convert from error to warning

@JLHwung
Copy link

JLHwung commented Dec 4, 2018

I don't suppose it's possible to do this when you're not using globs?

@derekdon Under the hood copy-webpack-plugin uses is-glob to detect whether it is a glob expression or not. So you can trick is-glob by constructing a glob expression essentially equivalent to a single file before this issue gets closed:

{
  context: path.resolve(__dirname, "a", "b"),
  from: "@(c)",
  to: "c"
}

If you need copy multiple files, simply write the glob expression for sure.

@D-Pow
Copy link

D-Pow commented Feb 26, 2023

I know this is a bit old, but came across this same issue recently and it seems the plugin has been updated with a noErrorOnMissing option that would solve this issue.

@YaminoYuki
Copy link

I know this is a bit old, but came across this same issue recently and it seems the plugin has been updated with a noErrorOnMissing option that would solve this issue.

This really useful..thanx

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

Successfully merging a pull request may close this issue.