-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsvelte.config.ts
More file actions
30 lines (25 loc) · 805 Bytes
/
svelte.config.ts
File metadata and controls
30 lines (25 loc) · 805 Bytes
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
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').replace(/\\/g, '/')
export const transformCssToJs = (css: string) =>
`import SVELTE_EVENTS from '${IMPORT_PATH}';
(() => {
var css;
SVELTE_EVENTS.PLUGIN_LOAD.subscribe(() => css = Blockbench.addCSS(${JSON.stringify(css)}));
SVELTE_EVENTS.PLUGIN_UNLOAD.subscribe(() => css?.delete());
})()`.replace(/[\t\n]/g, '')
export default { preprocess, transformCssToJs }