-
Notifications
You must be signed in to change notification settings - Fork 21
/
rollup.config.js
54 lines (51 loc) · 1.14 KB
/
rollup.config.js
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
51
52
53
54
import { defineConfig } from 'rollup';
import esbuild from 'rollup-plugin-esbuild';
/** @type {Record<string, string>} */
const mangleCache = {
_changed: '$ch',
_children: '$h',
_compute: '$c',
_context: '$cx',
_disposal: '$d',
_effect: '$e',
_handlers: '$eh',
_init: '$i',
_key: '$k',
_nodes: '$n',
_observers: '$o',
_refs: '$r',
_sources: '$s',
_state: '$st',
_value: '$v',
};
export default defineConfig([
// dev
define({ dev: true }),
// prod
define({ dev: false }),
]);
/** @returns {import('rollup').RollupOptions} */
function define({ dev = false }) {
return {
input: ['src/index.ts', 'src/core.ts', 'src/signals.ts', 'src/map.ts', 'src/symbols.ts'],
treeshake: true,
output: {
format: 'esm',
dir: `dist/${dev ? 'dev' : 'prod'}`,
chunkFileNames: '[name].js',
},
plugins: [
esbuild({
target: 'esnext',
platform: 'neutral',
tsconfig: 'tsconfig.build.json',
define: {
__DEV__: dev ? 'true' : 'false',
__TEST__: 'false',
},
mangleProps: !dev ? /^_/ : undefined,
mangleCache,
}),
],
};
}