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

Exclude src-tauri from relative devPath #1897

Closed
parker-codes opened this issue May 25, 2021 · 2 comments
Closed

Exclude src-tauri from relative devPath #1897

parker-codes opened this issue May 25, 2021 · 2 comments

Comments

@parker-codes
Copy link

Describe the bug
Not tested by me - came from Discord help-triage.

The developer said:

hi. The web side of my app is just hand-written html/css/js. I do not need a local development server. I would like the Tauri/Rust backend to be the server. What should I do when npm run tauri init asks me for the URL of my development server?

I replied that they can put a relative path instead of a dev server location. My example was to put ../, thinking that devs may keep their vanilla assets at the top level.

Noah highlighted that this may cause issues because it would then include /src-tauri. Obviously this can be bypassed if these are placed in a sub level, like /src.

Expected behavior
We should exclude the /src-tauri directory if pointed at the root level.

We could also add a hint in the docs that devs can use a relative path. This question has come up a few times recently.

@parker-codes
Copy link
Author

This recursive bit seems to be the part to change:

if !dev_path.starts_with("http") {
watcher.watch(
config
.lock()
.unwrap()
.as_ref()
.unwrap()
.build
.dev_path
.to_string(),
RecursiveMode::Recursive,
)?;
}

Though it's blocked by notify-rs/notify#204. No work has been done on it in a while, it seems.

@parker-codes
Copy link
Author

@amrbashir gave a good solution!

I don't think excluding src-tauri is the ideal solution because there will always be other files that needs to be excluded.
IMHO, we should advise against keeping keeping the assets in the root directory and always use dist or public.

A better solution might be to support 3 options for devPath and distDir:

  1. accepts a string that points to a directory or a dev server
  2. accepts a string that points to a single html file
  3. accepts an array of files

if they want to have their html file in the root directory, they should be able to, that's why I proposed the 2 later options.

But even then we should strongly recommend using a dist directory

what I am suggesting is the opposite of excluding and should be possible with notify crate (we would need multiple watchers if a user passes an array of files unfortunately)

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

No branches or pull requests

1 participant