Open herzadinata opened 2 weeks ago
Hmm, "works on my machine". Are you sure that it is actually using that config file? Does it fail as expected if you change the build command to some nonsense such as go build -o ./tmp/main ./nosuchdirectory
?
@istyf
Oh sorry, a little misunderstanding, i am not using it to build golang binary file, rather to watch / hot-reload my golang development environment.
...
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
exclude_dir = ["tmp", "node_modules"]
...
So that is for excluding directory on build
command? That's not what I want to do.
I want to watch the changes on my golang project but excluding that node_modules
from being watched.
So I tried to change the code above to this
...
root = "."
tmp_dir = "tmp"
exclude_dir = ["tmp", "node_modules"]
[build]
args_bin = []
...
That's still not excluding node_modules
from being watched. Is it capable of doing that?
No, it is not specific to the build command. It specifies what directories should be excluded from watching for changes.
What do you want to happen when air detects a file change? What is supposed to be reloaded and how?
Sorry, I didn’t notice that you moved exclude_dir out of the [build] section. That does not work.
If you remove lines from the toml those settings will be set to their default values, which aren’t necessarily empty. You need to change it back to have any hope of getting it to work.
If you do not want to build anything you need to set cmd to something that succeeds but does nothing. One example is here: https://github.com/air-verse/air/issues/632#issuecomment-2315259975
@istyf I meant building I don't want to build binary file for production, but building the binary file into tmp_dir
for watching purpose is is fine.
Okay so I changed back the exclude_dir:
Then run air by also pointing the air.toml. file:
But still the node_modules
is being watched:
I am expecting the node_modules
should not be watched as I specified in the exclude_dir
above.
I use: air v1.61.1, built with Go go1.23.2
This is my
.air.toml
file, put in the project root:But the
node_modules
dir in the project root is still being watched:Expectation: The
node_modules
should not be watched