Can I use glob or regex in serveStaticexclude option ?
router.get('/scripts/:file', ({ serveStatic }) => {
serveStatic('path/to/scripts', {
permanent: true, // ensure that files are permanently accessible, even after a new version of the site has been deployed.
exclude: ['some-non-versioned-file.js'], // you can exclude specific files from being served permanently. You should do this for any files that do not have a hash of the content in the name.
})
})
@ierceg looks like I’m blocked with permanent feature because of this. We have a lot of static files which we want to serve with XDN router. There is no way to make a dir list using node readDir because it gets bundled in a router and tries to read fs on lambda. We need an option with list of directories which will be scanned and excluded.
Could you just make separate routes for each directory? How many directories are there? What kinds of assets are these? In practice versioned assets all tend to be in a small handful of directories.
You could even use the regex capabilities of the router to make a route for only those directories that contain versioned assets.