-
Notifications
You must be signed in to change notification settings - Fork 12k
Allow exclusion of files / folders from being watched by @angular-devkit/build-angular:application
(ESBuild + Vite)
#26644
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
Comments
The watching is indeed not done by Vite, but this is done as part of the application builder implementation, a rebuild only happens when a file that is referenced in the application is modified. Can you provide the output of |
Thanks, sure:
To give you a clearer view: Everytime I change a pageobject, e2e-test, jest-test or one of the Cypress-tests generates an output within that library (i.e. "my-lib/reports"), a rebuild was triggered with webpack (and also with vite). Edit:
|
In the past, we didn't offer support for excluding files from the watcher, and it's not a feature we intend to introduce. However, it does seems there might be a bug in ng-packagr causing a library rebuild when a non-compilation file like If this is the case, I recommend filing an issue on https://github.com/ng-packagr/ng-packagr/. |
I'm trying to figure out how the files are marked as files to consider in the build with ESBuild. In build-action.js, I added some code to log the files that triggered a change:
I see that spec-Files and totally unrelated files show up here. Using The search led me to https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/tools/esbuild/bundler-execution-result.ts#L91 and codeBundleCache here https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/builders/application/execute-build.ts#L69 But then it gets blurry. I see the reference to the evn variable From the side of ESBuild I didn't find out anything.. I see that you can give ESBuild entrypoints, but that's it. I don't see how other files are included in the watched files.. |
Likely this is caused by some misconfiguration in your project:
|
We have TSConfigs that necessarily reference spec files and Cypress tests. The setup is done with NX: tsconfig.json in the root folder of the library:
and then tsconfig.spec.json and cypress/tsconfig.json include Jest- and Cypress-Tests but have different settings for the types, (for cypress/tsconfig.json -> When I running So I don't understand how the TSConfigs would affect the file watcher and how I could check how it is affecting the watcher. But thanks to your hints I found the culprit: The Tailwind configuration. It not documented very well on their website and according to some older issues, it seems that exclusions are not possible:
But NX, with its default setup, generates globPatterns that have some sort of exclusion: Not I can extend this glob pattern and possibly create an MR for NX to extend these exclusions per default (to also match cypress.config.ts, my-util.test.ts, my-other-test.cy.ts). As for now I'll ignore my huge ignore list for webpack and go on with the fixed Tailwind content globs and observe how the new watcher behaves with other files (as you see code-coverage output generated by Cypress was also a problem). Last problem to solve now is using
Previously we used In a new setup I tried it with Tailwind 3.0.2, 3.3.5 and 3.3.6 and none of these options work.. Possibly yet another misconfiguration.. :-( |
Glad to hear that you managed to fix the watching issues. The sass error is expected and valid in this case and is being thrown by the Sass compiler.
|
Is this a fundamental misunderstanding from my side? I thought I could use But still, it is very confusing because our setup works with Webpack and Tailwind (I don't know why it works) and it doesn't work with ESBuild. So something in the bundler must have changed too, since I didn't update Tailwind in my real project. Any ideas/hints other than to delete everything Tailwind-related and start from scratch? 😅 |
This should not work when when using SCSS with both webpack and esbuild based builder. This is because the Sass compiler runs before Tailwind and the latter is only invoked if the Sass compilation is successfully. In this cases the error is correct, the fact that it worked, was likely a bug in the Sass compiler that was fixed. Example of the error with Webpack when using Angular CLI version 17
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Command
serve
Description
According to https://angular.io/guide/esbuild it says:
The usage of Vite, much like the Webpack-based development server, is encapsulated within the Angular CLI dev-server builder and currently cannot be directly configured.
Webpack previously allowed a
customWebpackConfig
and therefore it was possible to exclude certain files and folders from the "watch" mechanism. With Vite this option is completely gone. In bigger setups with lots of libraries and Cypress/Jest tests residing in the folder of each library, the app gets rebuilt every time an irrelevant file (i.e.my-test.e2e.spec.ts
,my-test.spec.ts
ormy-test.cy.ts
) was changed.Especially creating and editing Cypress tests becomes a real an absolute struggle because you have to wait for the build to be completed before you can run a test properly.
What I also find strange is this line: https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts#L483
So where is the actual "watching" done, if not by Vite itself? Haven't found other hints..
Describe the solution you'd like
Ideas
Describe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered: