-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
48 lines (44 loc) · 1.26 KB
/
vite.config.ts
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
import { UserConfig, defineConfig } from 'vite';
// import cliPackageJSON from '../../cli/package.json';
const cliPackageJSON_version = '2.7.0';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const gamedev_build = process.env.VITE_WASM4_GAMEDEV_MODE !== "false";
let user_config: UserConfig = {
server: {
port: 3000,
open: '/?url=cart.wasm',
},
build: {
sourcemap: gamedev_build,
outDir: `dist/${gamedev_build ? 'developer-build' : 'slim'}`,
lib: {
entry: 'src/index.ts',
formats: ['iife'],
name: "wasm4",
fileName: () => `wasm4.js`,
},
rollupOptions: {
output: {
inlineDynamicImports: true,
assetFileNames: (assetInfo): string => {
if (assetInfo.name) {
if(/styles?\.css$/i.test(assetInfo.name)) {
return 'wasm4.css';
} else {
return assetInfo.name;
}
} else {
throw new Error("Unexpected condition, assetInfo had no name");
}
},
},
},
},
define: {
WASM4_GAMEDEV_MODE: gamedev_build,
WASM4_VERSION: JSON.stringify(cliPackageJSON_version),
},
};
return user_config;
});