-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
49 lines (46 loc) · 1.42 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
import * as path from 'path';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import { terser } from 'rollup-plugin-terser';
function getConfig(entry, filename, perf) {
// Remove the extension
let basename = filename.replace(/\.[^.]*/, '');
return {
input: entry,
output: {
dir: perf ? 'dist/perf' : 'dist',
entryFileNames: filename,
chunkFileNames: `${basename}-[name]-[hash].js`,
format: 'esm',
exports: 'named',
},
plugins: [
!perf &&
alias({
entries: {
'perf-deets': path.resolve(
__dirname,
'./node_modules/perf-deets/noop.js'
),
},
}),
webWorkerLoader({
pattern: /.*\/worker\.js/,
targetPlatform: 'browser',
external: [],
plugins: [terser()],
}),
nodeResolve(),
],
...(perf ? { external: ['perf-deets'] } : {}),
};
}
export default [
getConfig('src/index.js', 'index.js'),
getConfig('src/memory/backend.js', 'memory-backend.js'),
getConfig('src/indexeddb/backend.js', 'indexeddb-backend.js'),
getConfig('src/indexeddb/main-thread.js', 'indexeddb-main-thread.js'),
getConfig('src/indexeddb/backend.js', 'indexeddb-backend.js', true),
getConfig('src/indexeddb/main-thread.js', 'indexeddb-main-thread.js', true),
];