fixed date

This commit is contained in:
cpu
2025-05-09 23:19:39 +02:00
parent 824d977546
commit cb17a532c4

View File

@@ -6,15 +6,29 @@ import { resolve } from 'path';
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const appVersion = packageJson.version;
// Options for date formatting
const dateTimeFormatOptions = {
const now = new Date();
const dateTimeFormat = new Intl.DateTimeFormat('sk-SK', {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false // Use 24-hour format
};
// Generate build time string using Slovak locale
const appBuildTime = new Date().toLocaleString('sk-SK', dateTimeFormatOptions);
hour12: false
});
const parts = dateTimeFormat.formatToParts(now);
let day = '', month = '', year = '', hour = '', minute = '', second = '';
parts.forEach(part => {
switch (part.type) {
case 'day': day = part.value; break;
case 'month': month = part.value; break;
case 'year': year = part.value; break;
case 'hour': hour = part.value; break;
case 'minute': minute = part.value; break;
case 'second': second = part.value; break;
}
});
// Assemble the date part without unwanted spaces
const appBuildTime = `${day}.${month}.${year} ${hour}:${minute}:${second}`;
export default defineConfig({
plugins: [vue()],
@@ -29,24 +43,19 @@ export default defineConfig({
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
sw: resolve(__dirname, 'src/sw.js') // Assuming sw.js is now in src
sw: resolve(__dirname, 'src/sw.js')
},
output: {
entryFileNames: assetInfo => {
// Output service-worker.js to the root of the dist directory
if (assetInfo.name === 'sw') {
return 'service-worker.js'; // Ensure consistent name
return 'service-worker.js';
}
// Default naming for other entry points/chunks
return 'assets/[name]-[hash].js';
},
// For chunks, if any are generated from sw.js (unlikely for simple SW)
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
}
},
// Set to false if you don't want to empty the dist dir on each build
// but usually true is good for clean builds.
emptyOutDir: true,
}
});