-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathvite.config.headless.mts
More file actions
50 lines (45 loc) · 1.5 KB
/
Copy pathvite.config.headless.mts
File metadata and controls
50 lines (45 loc) · 1.5 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
import { resolve } from 'node:path';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { sveltePreprocess } from 'svelte-preprocess';
import { defineConfig, loadEnv } from 'vite';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import { svgRaw, transportWorklet } from './vite.config.mts';
const ASSET_PATH = process.env.ASSET_PATH || 'https://ameo.dev/web-synth-headless/';
export default defineConfig(({ mode }) => {
const env = { ...loadEnv(mode, __dirname, ''), ...process.env };
return {
plugins: [
svelte({ preprocess: [sveltePreprocess({ typescript: {} })] }),
svgRaw(),
cssInjectedByJsPlugin(),
transportWorklet(),
],
resolve: {
alias: { src: resolve(__dirname, 'src') },
},
json: { stringify: true, namedExports: false },
publicDir: false,
base: ASSET_PATH,
define: {
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
'process.env.BACKEND_BASE_URL': JSON.stringify(env.BACKEND_BASE_URL || ''),
'process.env.FAUST_COMPILER_ENDPOINT': JSON.stringify(env.FAUST_COMPILER_ENDPOINT || ''),
},
worker: {
format: 'es' as const,
},
build: {
target: 'es2022',
sourcemap: true,
outDir: 'dist/headless',
rolldownOptions: {
input: resolve(__dirname, 'src/headless/index.tsx'),
preserveEntrySignatures: 'exports-only' as const,
output: {
format: 'es' as const,
entryFileNames: 'headless.js',
},
},
},
};
});