question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite doesn't detect changes in files in target/flow-frontend

See original GitHub issue

Description of the bug

We have a maven multimodule project where js/ts files from different maven modules end up in target/flow-frontend directory. Once the server is started for the first time (in development mode), vite creates the node_modules/.vite folder and it works. However any time I make a change in other modules and the updated file gets to target/flow-frontend, vite doesn’t detect the change until I manually delete the node_modules/.vite directory and restart the server. We even have a custom file watcher implemented which copies the modified files from src/main/resources/META-INF/resources/frontend from other modules to target/flow-frontend even when the server is running - this caused webpack to reload the page and the changes were effective even without server restart. However this doesn’t work with vite, not even with server restart.

Versions:

- Vaadin / Flow version: 23.2.2
- Java version: 17
- OS version: Mac OS 12.6
- Browser version (if applicable): Chrome 105.0.5195.125
- Application Server (if applicable): Spring boot 2.7.3 with embedded tomcat
- IDE (if applicable): Intellij IDEA
- Development or production mode: development

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
F0rcecommented, Oct 30, 2022

any updates ?

1reaction
ggecycommented, Oct 7, 2022

Thanks for the information. @ggecy do you mind sharing some information about your file watcher solution?

I don’t see any button to attach the file here, so I tried to share it on goodle drive: https://drive.google.com/file/d/1P-1umxNEKjkMxp2iBP0IFJbWOTr6R-jt/view?usp=sharing

The file is experimental, not a clean code, but it works… Feel free to modify it for your needs. It will try to find all META-INF/resources/frontend, META-INF/frontend and META-INF/resources/themes folders in any target folder of your modules on classpath and copies them to target/flow-frontend folder in your bootstrap module whenever it detects a change with slight delay to avoid duplicate activations. Also you need to press compile button in Intellij Idea if you modify your js/ts/css files in mentioned folders so they get copied to target (it doesn’t watch the src folder). It doesn’t do anything by itself, you need to register it as listener when starting your spring boot application:

public static void main(String[] args) {
        SpringApplication application = new SpringApplication(YourApplication.class);
        application.addListeners(new WebpackFrontendResourceExtractor());
        application.run(args);
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vite HMR doesn't detect changes to components nested under ...
The problem is vite doesn't detect changes (ctrl+s) in A.vue or B.vue i.e., components nested under NestedFolder in components folder.
Read more >
Production Build | Deploying to Production | Vaadin Docs
This builds a JAR or WAR file with all the dependencies and transpiled front-end resources, ready to be deployed. The file can be...
Read more >
Troubleshooting - Vite
Vite does not detect a file change​​ If you are running Vite with WSL2, Vite cannot watch file changes in some conditions. See...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
However, tree-shaking is not the only speed/performance benefit of Rollup. See Rich ... Part I: How to Use Rollup to Process and Bundle...
Read more >
Changelog | Cypress Documentation
This change aligns with how the cy.visit() command generates urls with ... Cypress will no longer watch files when executing component tests in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found