many many fixes
This commit is contained in:
32
vite.config.js
Normal file
32
vite.config.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import fs from 'node:fs';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
const VERSION_FILE = new URL('./src/version.json', import.meta.url);
|
||||
|
||||
// src/version.json is imported by the app (baked into the bundle) and also
|
||||
// published as /version.json, which running clients poll to detect new deploys.
|
||||
function versionFilePlugin() {
|
||||
return {
|
||||
name: 'quartiles-version-file',
|
||||
// Dev: always serve the current file contents, uncached
|
||||
configureServer(server) {
|
||||
server.middlewares.use('/version.json', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
res.end(fs.readFileSync(VERSION_FILE, 'utf8'));
|
||||
});
|
||||
},
|
||||
// Build: emit dist/version.json
|
||||
generateBundle() {
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: 'version.json',
|
||||
source: fs.readFileSync(VERSION_FILE, 'utf8')
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [versionFilePlugin()]
|
||||
});
|
||||
Reference in New Issue
Block a user