-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (63 loc) · 1.98 KB
/
vite.config.ts
File metadata and controls
71 lines (63 loc) · 1.98 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default defineConfig({
// Configure how Vite handles different file types
assetsInclude: ['**/*.html'],
// Configure the development server (optional, for demo serving)
server: {
port: 3000,
open: '/index.html',
},
// Configure build options
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: true, // Include source maps
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'gridSight',
fileName: 'grid-sight',
formats: ['iife'],
},
rollupOptions: {
// Make sure to externalize deps that shouldn't be bundled
external: [],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {},
// Set the global variable name for the IIFE build
name: 'gridSight',
// Ensure the global variable is properly set
extend: true,
// Use a self-executing function to ensure proper scoping
intro: 'var gridSight;',
outro: 'window.gridSight = gridSight;',
},
},
// Ensure all assets are properly copied
assetsInlineLimit: 0,
// Minify the output
minify: 'terser',
},
// Configure how modules are resolved
resolve: {
alias: {
// Add any path aliases here if needed
},
},
// Configure plugins
plugins: [
// Add any other Vite plugins here
],
// Configure public directory for static assets
publicDir: 'public',
// Base public path. Honour an explicit VITE_BASE_PATH override so PR-preview
// builds can land under `/grid-sight/pr-preview/<NUM>/` without breaking
// asset resolution. Falls back to the production / dev defaults.
base: process.env.VITE_BASE_PATH
|| (process.env.NODE_ENV === 'production' ? '/grid-sight/' : '/'),
});