-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
37 lines (33 loc) · 1.01 KB
/
Copy pathvite.config.js
File metadata and controls
37 lines (33 loc) · 1.01 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
import { defineConfig } from 'vite'
import { viteSingleFile } from 'vite-plugin-singlefile'
// Custom plugin to automatically attach classes to the window object
const exposeGlobals = (classes) => {
return {
name: 'expose-globals',
transform(code, id) {
// Inject the window assignment into the module.
// Rollup will automatically map 'cls' to whatever internal
// name (like CTensor$1) it generates during bundling.
const injections = classes
.map(cls => `if (typeof ${cls} !== 'undefined') window.${cls} = ${cls};`)
.join('\n');
return {
code: code + '\n' + injections,
map: null
};
}
};
};
export default defineConfig({
plugins: [
viteSingleFile(),
// List the exact names of the classes as they appear in your source code
exposeGlobals(['CTensor'])
],
build: {
outDir: 'dist',
assetsInlineLimit: 100000000,
cssCodeSplit: false,
minify: false, // Leave false to keep the bundled code readable
}
})