-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvelte.config.ts
32 lines (27 loc) · 860 Bytes
/
svelte.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
import { resolve } from 'path'
import prep from 'svelte-preprocess'
import { typescript } from 'svelte-preprocess-esbuild'
export const compilerOptions = {
dev: process.env.NODE_ENV === 'development',
css: true,
}
export const preprocess = [
typescript({
target: 'es2022',
define: {
'process.browser': 'true',
},
}),
prep({ typescript: false }),
]
const IMPORT_PATH = resolve(__dirname, '../src/util/', 'events.ts')
export const transformCssToJs = (
css: string
) => `import { events as SVELTE_EVENTS } from ${JSON.stringify(IMPORT_PATH)};
(() => {
const $deletable = Blockbench.addCSS(${JSON.stringify(css)});
function DELETE_SVELTE_CSS() { $deletable?.delete() }
SVELTE_EVENTS.UNLOAD.subscribe(DELETE_SVELTE_CSS, true);
SVELTE_EVENTS.UNINSTALL.subscribe(DELETE_SVELTE_CSS, true);
})()`
export default { preprocess, transformCssToJs }