-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
63 lines (59 loc) · 1.56 KB
/
rollup.config.mjs
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
55
56
57
58
59
60
61
62
63
import path from 'path';
import { fileURLToPath } from 'url';
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import copy from 'rollup-plugin-copy';
import wasm from '@rollup/plugin-wasm';
import { terser } from 'rollup-plugin-terser';
import livereload from 'rollup-plugin-livereload';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
const production = !process.env.ROLLUP_WATCH;
// Fix path resolution for ESM
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const basePlugins = [
resolve({
extensions: ['.ts', '.js', '.json', '.wasm'],
browser: true,
preferBuiltins: false,
}),
replace({
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
preventAssignment: true,
}),
typescript({
tsconfig: './tsconfig.json',
clean: true,
}),
commonjs(),
wasm(),
copy({
targets: [{ src: 'src/wasm/*', dest: 'dist/wasm' }],
}),
terser(),
livereload('dist'),
webWorkerLoader({
inline: true,
targetPlatform: 'browser',
extensions: ['.ts'],
})
];
export default [
{
input: './src/index.ts',
output: {
dir: './dist',
format: 'esm',
sourcemap: true,
entryFileNames: 'index.esm.js',
},
external: ['rxjs', 'nostr-tools', 'wasm/notemine.js'],
plugins: basePlugins,
watch: {
exclude: 'node_modules/**',
clearScreen: false,
},
},
];