-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
35 lines (33 loc) · 972 Bytes
/
vite.config.js
File metadata and controls
35 lines (33 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { readFileSync } from 'node:fs';
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
const civio = pkg.civio || {};
export default defineConfig({
base: './',
define: {
__APP_ID__: JSON.stringify(civio.appId || ''),
__PROJECT_PATH__: JSON.stringify(civio.projectPath || ''),
__INVESTIGATION_URL__: JSON.stringify(civio.investigationUrl || null),
},
build: {
rollupOptions: {
output: {
entryFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]',
},
},
},
plugins: [
svelte(),
{
name: 'html-transform',
transformIndexHtml(html) {
const timestamp = Date.now();
return html
.replace(/assets\/index\.js/g, `assets/index.js?v=${timestamp}`)
.replace(/assets\/index\.css/g, `assets/index.css?v=${timestamp}`);
},
},
],
});