-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[feat] Add .taurignore and turn off the default behavior of watching all workspace members #4617
Comments
This feature is very nice. i need it |
What if we add a [tauri] section to the workspace Cargo.toml file where you can configure which packages to include or which packages to ignore? |
I considered this approach as well but then figured that it's far more standardized to use a .ignore file of some kind. It's an option, but in my opinion it's preferable to add .taurignore anyway because it makes it easier to handle the ignores. The workspace file can get pretty bloated otherwise and it's easier to manage ignores in different crates if each crate has its own Yet another option could be |
My only nit-pick feedback is the file name missing an 'i'. I know why (and we do the same with tauricon) but it still seems off. .tauri-ignore is outside the convention given by .gitignore but could it be an option? |
Personally I like the name |
Agree that End of the day it doesn't matter, just wanted to put it out there. |
my vote goes to : |
If this feature request turns into a discussion about the name of a file and not about the feature itself we may take the easy route and accept all 4 variants and let each user decide for themself 😆 |
I like |
Regex of |
Shouldn't we much rather discuss this
and this
? 😆 P.S. it's 3v2 in favor of .taurignore right now 👀 (Edit: yes, my muscle memory wrote .gitignore)
Now that's what i'm talking about |
may be providing a key also one more esoteric name |
I think we should disable watching by default (not only on workspaces) and enable it behind a |
Luckily that one isn't a valid file name 😂 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Hmm, not really a fan of that one. imo it would be especially weird for devs with a webtech background (because of the bundlers all having HMR and stuff). They probably don't do much rust dev, but at least change the config somewhat regularly. |
I think watching the Tauri project directory should be on by default, but maybe add an option to disable it with If you wanna add Or, if you make watching the project the default, you can just have Regardless of approach chosen for the CLI options I think that at least so far it's clear that some manner of ignore file is desired, and as long as ignore files get added it doesn't matter THAT much which CLI options are added, if everything is watched everywhere by default then you can just work with the ignore files to disable the behavior where it shouldn't be applied So the most important thing to do right now is discuss the name of the ignore file and implement that function. CLI options are desired but aren't immediately necessary to fix the issue |
Let's go with the ignore file and |
Just to be clear here, when you say |
How about |
It's enought that just |
Ok story time. 6 years in the future you're reading this issue, because you just spent the whole day troubleshooting, why watches went weird since about last month at your company. You set out to fix it, once and for all. It turns out, your monorepo with 50-or-so packages had some quirky git submodules pulled in. In fact, even your first attempt didn't work. In short, I believe we should pick one name, and be prepared to support it until the end of time. While the magic of |
I'm completely on board with what @Beanow said, we need to have one format, one filename and very well defined behaviour. So let's think this through proper before merging #4623. What should it mean for a file to be included in the IMO there is too much left unanswered yet. Edit: Also what about removing the custom watching feature entirely and just pre-filling the |
|
I think .taurignore should only apply for the dev watcher and app path resolver since the bundler has its own configuration and we can add exclude rules in there later. |
I agree that |
When will feature |
@mokeyish It's already a thing. But for now you need to manually specify it via an env var, like described in the original issue description:
|
Thanks |
@FabianLars Hi, Reading ignore files seems not enabled. tauri/tooling/cli/src/interface/rust.rs Line 242 in 7bbf167
|
This is something different. Adding custom ignore files via the env var works (and |
It dose't work when I add any file to Project structure.
├── crates
├── scripts
│ ├── cross-run.bat # use git bash to run cross-run.sh on windows.
│ └── cross-run.sh # load .env if exits
├── src
│ ├── ui # web project
│ └── main.rs
├── Cargo.toml
├── .taurignore # content: `src/ui/`
├── package.json
├── tauri.conf.json
├── .env # conrent: `export TAURI_DEV_WATCHER_IGNORE_FILE=.taurignore`
file: package.json {
"license": "MIT",
"private": true,
"workspaces": [
"src/ui"
],
"scripts": {
"dev": "scripts/cross-run concurrently -k npm:vite-dev npm:tauri-dev",
"build": "npm run vite-build && npm run tauri-build",
"tauri-dev": "tauri dev",
"tauri-build": "tauri build",
"vite-dev": "vite src/ui",
"vite-build": "vite build src/ui",
"vite-preview": "vite preview src/ui"
}
}
file: @echo off
chcp 65001 >nul 2>&1
FOR /F "tokens=*" %%g IN ('where git') do (SET GIT_PATH=%%g)
FOR %%i IN ("%GIT_PATH%") DO (SET GIT_DIR=%%~di%%~pi)
SET SHELL_CMD="%GIT_DIR%bash.exe" -c "scripts/cross-run.sh %*"
%SHELL_CMD% file: cross-run.sh #!/usr/bin/env bash
if [[ "$1" == "scriptsenv-run" ]]; then
shift
fi
[ -f .env ] && source .env
cmd=$@
bash -c "$cmd" |
While not strictly related to If I run: export TAURI_DEV_WATCHER_IGNORE_FILE=$(pwd)/.taurignore
cargo tauri dev and then edit |
@eliaperantoni i'm not entirely sure and imo the ignore stuff feels a little wonky, but i think the taurignore file needs to be next to the tauri.conf.json file with paths relative to that file (and set the env var to just p.s. i'm not really experienced with the ignore thingy so maybe i got something wrong, but this is how i made it work for me. |
I tried your suggestion but it, unfortunately, didn't work 😔. The I noticed the watcher is implemented using the ignore crate. Whenever a workspace is used, every member's path is recursively walked using a tauri/tooling/cli/src/interface/rust.rs Lines 202 to 224 in c53d9ea
Notice tauri/tooling/cli/src/interface/rust.rs Line 215 in c53d9ea
tauri/tooling/cli/tauri-dev-watcher.gitignore Lines 1 to 3 in f48b1b0
When tauri/tooling/cli/src/interface/rust.rs Lines 216 to 218 in c53d9ea
So I did some experimentation:
The fact that the default filter seems to be working as intended while the custom one doesn't, even though they're loaded in the very same way, is only short of magical 🔮. Possible workarounds:
If this is affecting more people I'd be happy to investigate further on the issue and, possibly, come up with a PR. If anyone else could try running the minimal example I provided in #4617 (comment) to see if it works, that could be useful. Although I think it's unlikely this issue is related to my machine. |
If anyone will come here in future confused as me -> here's the solution 👇
At first
Next problem was that tauri decided to do the same 😄 I'm not gonna waste my time figuring out why but i decided to move
After this i had perfect setup, where my tauri window reloads only when src-tauri folder updated and when frontend folder updated - it only triggers content (html) to update. Tauri please add somewhere docs about how to configure multi member projects. |
Was just reading this discussion because I knew .taurignore existed but wasn't sure what dir it was in, For those here, it is in the root dir of the project at the same level as .gitignore. |
Finally after hours of attempts and research I found the correct placement for
|
sorry to bump the thread. But i think i now use https://github.com/tauri-apps/create-tauri-app for generatign the yew + tauri project that reduce the issues. cargo install create-tauri-app
cargo create-tauri-app |
thanks for your advice,it work!! |
This definitely needs to be documented for people using Rust To add a few examples:Say your In
These don't work:
surprisingly, if you specifically want to NOT to watch a subfolder under
|
I agree but where would you expect to find this in the docs? Genuine question as we're currently rewriting the docs and i have no idea where to put this. |
I would suggest maybe a note under getting started you could include a note for .gitignore and a .tauriignore section about setting up the dev environment. |
I would imagine a sub-section or a separate page under https://beta.tauri.app/guides/develop/ Which is about the DX experience, including things like setting up IDEs for Tauri dev., where best to place shared env variables and keys, how to set up auto-reloads (where |
Hmm yeah, i like that. Thank you! |
I'm trying to ignore everything in my It seems like this was closed and merged 2 years ago. I can't seem to find any documentation online other than this thread. Help appreciated! I found a mention of it in these release notes: https://tauri.app/blog/2022/09/15/tauri-1-1/ I'm using EDIT: found this guy saying the trailing asterisk is necessary: https://github.com/eliaperantoni/spaceman/blob/main/.taurignore I've now tried
and it still doesn't ignore that folder Everyone here says to place it in root, but this tweet says to place it inside src-tauri https://x.com/CrabNebulaDev/status/1743297603213935063 |
Assuming i understand you correctly then this is not what .taurignore is about. The ignore file is only for the file system watcher to ignore changes to the ignored paths so that the app doesn't get recompiled. It does not influence what files are built or included in builds. If you want to exclude files from your devPath/distDir then this is up to your frontend bundler (if you use just tauri and no frontend bundler then tauri can't do it). |
Ah, yeah I think I misunderstood what the file is for. I just wanted to ignore some screenshots that are used for SEO only. Thanks for the quick and well explained reply! I'll look into my bundler. Thanks again. |
I ended up doing it in a node script: // Delete files that aren't necessary for tauri so they don't get bundled with the tauri app
import fs from 'fs';
// Delete img folder
const paths = ['build/img'];
for (const path of paths) {
if (fs.existsSync(path)) {
fs.rmSync(path, { recursive: true });
console.log(`Deleted ${path}`);
}
} And then calling that before build in "beforeBuildCommand": "npm run build && node infrastructure/clean-tauri.js" This way it first builds, then removes the built screenshots and then builds tauri, so the source screenshots aren't deleted and I don't need to manually do anything or touch the normal app logic. Also no dependencies. Of course you could just use |
Describe the problem
I use a monolithic style repository. Crates in my repository can be completely unrelated to the Tauri app, such as the REST API. But even if it's related to the app, for example the frontend resides in a separate workspace member than the Tauri source code. The result of watching all workspace members then is that rather than having hot reloading for my frontend, any change to the frontend results in the Tauri app being rebuilt as well. If I update the API, Tauri rebuilds, for absolutely no good reason. Even if I just change the README in another project, it triggers a rebuild of the Tauri app.
The only solution right now for me that sort of works is by passing an ignore file as an environment variable in the format of
TAURI_DEV_WATCHER_IGNORE_FILE=.taurignore
. It works, but passing that environment variable is incredibly annoying.Describe the solution you'd like
--watch-members
to enable it. It's a good feature but I highly doubt most people using workspaces are using every single crate in their workspace for the Tauri project. If you disagree, at least add the reverse option, e.g.--no-watch-members
.taurignore
that disable watchers for ignored filesAlternatives considered
None really. I'll use my workaround until either of the above solutions are implemented, or until someone else suggests something better.
One potential improvement to the watched files could be only watching for changes in
*.rs
files in other workspace members, since it's pretty much guaranteed that the only reason you want to rebuild your Tauri app based on a workspace member change is when you've updated the Rust code. Icons and such most likely reside in the Tauri project itself so watching the entire Tauri project makes sense, but watching all files in all workspace members is almost guaranteed to be unnecessary and unwanted behavior, watching all Rust files should be the only thing people really need. Ignore files would still be required because again, if I have a REST API, I don't want those Rust source files to rebuild my Tauri app as well, but it'd be a start.Additional context
No response
The text was updated successfully, but these errors were encountered: