23 lines
646 B
TypeScript
23 lines
646 B
TypeScript
import { defineConfig } from '@adonisjs/static'
|
|
|
|
/**
|
|
* Serves the Angular build copied in "public/". The bundles have a hash
|
|
* in their name and can be cached forever, index.html must not be cached.
|
|
*
|
|
* https://docs.adonisjs.com/guides/static-assets
|
|
*/
|
|
const staticServerConfig = defineConfig({
|
|
enabled: true,
|
|
etag: true,
|
|
lastModified: true,
|
|
dotFiles: 'ignore',
|
|
headers: (path) => {
|
|
if (/(^|[\\/])(main|chunk|styles|polyfills)-[\w-]{8,}\.(js|css)$/.test(path)) {
|
|
return { 'Cache-Control': 'public, max-age=31536000, immutable' }
|
|
}
|
|
return { 'Cache-Control': 'no-cache' }
|
|
},
|
|
})
|
|
|
|
export default staticServerConfig
|