-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
112 lines (110 loc) · 3.42 KB
/
vite.config.js
File metadata and controls
112 lines (110 loc) · 3.42 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { versionPlugin } from './vite-plugin-version.js';
// Plugin to suppress source map warnings for third-party dependencies
// These warnings occur because igv-ui and igv reference CSS source maps that don't exist
function suppressSourceMapWarnings() {
return {
name: 'suppress-sourcemap-warnings',
configureServer(server) {
// Intercept WebSocket messages to filter out source map errors
const originalSend = server.ws.send;
server.ws.send = function (payload) {
if (payload.type === 'error' && payload.err) {
const errorMessage = payload.err.message || payload.err.toString() || '';
// Suppress warnings about missing CSS source maps for igv dependencies
if (errorMessage.includes('igv-ui.css.map') ||
errorMessage.includes('Failed to load source map')) {
return; // Don't send this error to the client
}
}
return originalSend.call(this, payload);
};
},
};
}
export default defineConfig({
root: '.',
publicDir: 'public',
server: {
port: 5173,
open: '/index.html',
},
preview: {
port: 5173,
open: '/index.html',
},
css: {
preprocessorOptions: {
scss: {
// SCSS options if needed
},
},
},
build: {
// Standard app build (not library mode) for local frontend
outDir: 'dist',
assetsDir: 'assets',
minify: true,
sourcemap: true, // Enable sourcemaps for local development
cssCodeSplit: false, // Extract all CSS into a single file
rollupOptions: {
input: resolve(__dirname, 'index.html'),
output: {
assetFileNames: (assetInfo) => {
// Ensure CSS is named juicebox.css
if (assetInfo.name && assetInfo.name.endsWith('.css')) {
return 'css/juicebox.css';
}
return assetInfo.name || 'assets/[name][extname]';
},
},
},
},
plugins: [
versionPlugin(),
viteStaticCopy({
targets: [
{ src: 'css/img', dest: 'css/' },
],
}),
suppressSourceMapWarnings(),
],
resolve: {
alias: {
'@': resolve(__dirname, './'),
},
},
// Custom logger to suppress source map warnings for third-party dependencies
customLogger: {
warn(msg, options) {
// Filter out source map warnings for igv dependencies
const message = typeof msg === 'string' ? msg : String(msg);
if (message.includes('igv-ui.css.map') ||
message.includes('Failed to load source map') ||
(message.includes('ENOENT') && message.includes('igv'))) {
return; // Suppress these warnings
}
// Use default warning logger for other messages
console.warn(msg, options);
},
error(msg, options) {
// Filter out source map errors for igv dependencies
const message = typeof msg === 'string' ? msg : String(msg);
if (message.includes('igv-ui.css.map') ||
message.includes('Failed to load source map') ||
(message.includes('ENOENT') && message.includes('igv'))) {
return; // Suppress these errors
}
// Use default error logger for other messages
console.error(msg, options);
},
info(msg, options) {
console.info(msg, options);
},
clearScreen() {
// Keep default clear screen behavior
},
},
});