Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
121 lines (119 loc) · 3.77 KB
/
Copy pathvite.config.js
File metadata and controls
121 lines (119 loc) · 3.77 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
113
114
115
116
117
118
119
120
121
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { versionPlugin } from './vite-plugin-version.js';
import { devProxy } from './dev-proxy/plugin.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: 3000,
open: '/dashboard.html',
},
preview: {
port: 3000,
open: '/dashboard.html',
},
css: {
preprocessorOptions: {
scss: {
// SCSS options if needed
},
},
},
build: {
lib: {
entry: 'js/index.js',
name: 'juicebox',
formats: ['es', 'umd'],
fileName: (format) => {
if (format === 'es') return 'juicebox.esm.js';
return 'juicebox.min.js';
},
},
outDir: 'dist',
minify: true, // Use esbuild (faster, built into Vite)
sourcemap: true,
cssCodeSplit: false, // Extract all CSS into a single file
rollupOptions: {
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(),
// Dev only (apply: 'serve'). Pairs with hic.setUrlMapper(devMapUrl) on the pages that load
// maps from a host that serves a bot challenge. See docs/adr/0001-dev-proxy-for-waf-protected-hosts.md.
devProxy(),
viteStaticCopy({
targets: [
{ src: 'css/img/*', dest: 'css/img', rename: { stripBase: true } },
],
}),
suppressSourceMapWarnings(),
],
resolve: {
alias: {
'@': import.meta.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
},
},
});