-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
110 lines (107 loc) · 2.33 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'
import url from '@rollup/plugin-url'
import { string } from 'rollup-plugin-string'
import { terser } from 'rollup-plugin-terser'
const plugins = [
resolve(),
babel(),
]
const pluginModules = [
'esmodule',
'sucrase',
]
export default pluginModules
.map((pluginModule) => (
{
input: `src/plugins/${pluginModule}/worker.js`,
output: [
{
file: `dist/workers/${pluginModule}.plugin.txt`,
format: 'iife',
},
],
plugins: plugins
.concat([
commonjs(),
terser({
compress: {
drop_debugger: false,
},
}),
]),
}
))
.concat(
pluginModules.map((pluginModule) => (
{
input: `src/plugins/${pluginModule}/index.js`,
output: [
{
file: `dist/plugins/${pluginModule}.cjs.js`,
format: 'cjs',
exports: 'default',
},
{
file: `dist/plugins/${pluginModule}.esm.js`,
format: 'es',
},
{
file: `dist/plugins/${pluginModule}.js`,
format: 'umd',
name: `VmWorker${pluginModule[0].toUpperCase()}${pluginModule.substr(1)}Plugin`,
},
],
plugins: plugins.concat(
string({
include: '**/*.txt',
}),
),
}
)),
)
.concat([
{
input: 'src/worker/index.js',
output: [
{
file: 'dist/workers/vm-worker.worker.txt',
format: 'iife',
},
],
plugins: plugins
.concat([
terser({
compress: {
drop_debugger: false,
},
}),
]),
},
{
input: 'src/index.js',
output: [
{
file: 'dist/vm-worker.cjs.js',
format: 'cjs',
exports: 'default',
},
{
file: 'dist/vm-worker.esm.js',
format: 'es',
},
{
file: 'dist/vm-worker.js',
format: 'umd',
name: 'VmWorker',
},
],
plugins: plugins.concat(
url({
include: ['**/*.txt'],
limit: Infinity,
}),
),
},
])