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

[suggestion] throws an error when it doesn't find the file/path #126

Closed
tassioFront opened this issue Sep 9, 2024 · 8 comments · Fixed by #127
Closed

[suggestion] throws an error when it doesn't find the file/path #126

tassioFront opened this issue Sep 9, 2024 · 8 comments · Fixed by #127
Labels
enhancement New feature or request PR welcome

Comments

@tassioFront
Copy link
Contributor

[suggestion] throws an error when it doesn't find the file

I have been using the vite-plugin-static-copy for a while and recently I needed to move the file path it copies. So, I changed the copied file from src/old-path to src/new-path, but I forgot to update the plugin configuration:

  viteStaticCopy({
     targets: [
       {
         src: './src/old-path.js', // I must update this line, but even without doing it the build keeps working.
         //...more config
       },
     ],
   }),

Unfortunately, it does not throw any error, so I noticed it fails after manual validations. Does make sense to throw an error when the plugin doesn't find the file?

@sapphi-red
Copy link
Owner

I think we can have a warning log in build.

@sapphi-red sapphi-red added enhancement New feature or request PR welcome labels Sep 12, 2024
@tassioFront
Copy link
Contributor Author

To be honest, I think it should fail once the application won't work as expected, but a warning would help a lot. 🙌

@tassioFront
Copy link
Contributor Author

tassioFront commented Sep 13, 2024

@sapphi-red, I was creating the PR when I saw this on my terminal:
Screenshot from 2024-09-13 15-14-52

This validation is done here

Guess it proves the warning is not enough. 😅 Anyway, let me know if makes sense to open the PR with an error msg; or I can keep the warning, but change the message like:

'No file was found to copy on ${src} src.'

otherwise, we can close the issue.

@tassioFront
Copy link
Contributor Author

@sapphi-red what do you think?

@sapphi-red
Copy link
Owner

Hmmm, yeah, probably an error is better.
But I think throwing an error will break usecases like slidev (#52).

So I think we need to cut a major version and also add an option to ignore the error.

@tassioFront
Copy link
Contributor Author

tassioFront commented Sep 25, 2024

@sapphi-red perfect!

Let me know what you think about this changes.

@sapphi-red sapphi-red linked a pull request Oct 9, 2024 that will close this issue
@vedranstipancic
Copy link

vedranstipancic commented Dec 18, 2024

This seriously hindered the way we use the plugin.
We have a common vite config for several projects. It includes some things to copy which are optional on projects. Until now it wasn't an issue, because it just didn't copy things it didn't find.
Now it

  • breaks my build if nothing found
  • if I turn on silent absolutely nothing gets copied, because one of the copies failed
  • if I break up one copy into several copies, it doesn't work during development

It feels like we'd need the silent option on each target.

@tassioFront
Copy link
Contributor Author

@vedranstipancic, which version were you using before it started, and which one now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants