How to exclude files from Astro dev (watch)

This article was published on Sep 24, 2023, and takes approximately a minute to read.

I have a VSCode extension installed called History. It's damn useful because it creates a copy of every single file I touch, which saved me a couple of times when I accidentally removed a file that was not committed yet.

This extension creates a folder called .history, which I obviously ignore at the global level to avoid accidentally committing it to any project. Still, some dev servers track the whole folder for changes, and that was Astro's case.

Astro dev server - update when .history file has changed
Astro dev server - update when .history file has changed

Because Astro uses Vite, we can ignore certain files from the watch mode:

import { defineConfig } from "astro/config";

import tailwind from "@astrojs/tailwind";

export default defineConfig({
  integrations: [tailwind()],
  vite: {
    server: {
      watch: {
        ignored: ["**/.history/**/*"], // HERE

And now any file in that folder will be simply ignored.