30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
|
|
/** Build the real application with fresh asset URLs for a cold HTTP-cache probe.
|
||
|
|
* Does not clear user data, browser settings, login state or business records.
|
||
|
|
* This replaces am-web/dist; restart the frontend preview after it finishes.
|
||
|
|
*/
|
||
|
|
import { build } from '../am-web/node_modules/vite/dist/node/index.js'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
import { writeFile } from 'node:fs/promises'
|
||
|
|
|
||
|
|
const webRoot = fileURLToPath(new URL('../am-web/', import.meta.url))
|
||
|
|
process.chdir(webRoot)
|
||
|
|
const assetPrefix = `cold-${Date.now()}`
|
||
|
|
await build({
|
||
|
|
mode: 'env.local',
|
||
|
|
build: {
|
||
|
|
manifest: true,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
entryFileNames: `assets/${assetPrefix}-[name]-[hash].js`,
|
||
|
|
chunkFileNames: `assets/${assetPrefix}-[name]-[hash].js`,
|
||
|
|
assetFileNames: `assets/${assetPrefix}-[name]-[hash][extname]`
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
await writeFile(new URL('../.local/frontend-cold-probe.json', import.meta.url), JSON.stringify({
|
||
|
|
assetPrefix,
|
||
|
|
method: 'Fresh asset URLs; validate cachedAssets=0 and revalidatedAssets=0 on the first browser load. Browser process, DNS and authenticated session remain warm.'
|
||
|
|
}, null, 2))
|
||
|
|
console.log(`Cold asset-cache probe build: ${assetPrefix}`)
|