The netlify dev
command automatically reloads a function file when that file changes. However, if that file imports others, and one of those imported files change, no reload occurs.
Is there any way to make netlify dev
watch for changes to imported files?
Would still prefer an official solution, but for anyone looking for a workaround, I’m using tsc-watch
in order to make use of its --onSuccess
handler so that I can run my own script:
import fs from 'fs'
import path from 'path'
import touch from 'touch'
const FUNCTIONS_DIR = path.join(__dirname, '../src/backend/lambda/functions')
for (const file of fs.readdirSync(FUNCTIONS_DIR)) {
if (!file.endsWith('.js')) continue // Skip *.js.map files
touch(path.join(FUNCTIONS_DIR, file))
}