-
Notifications
You must be signed in to change notification settings - Fork 16
/
rollup.config.mjs
61 lines (57 loc) · 1.5 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
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'
import css from 'rollup-plugin-import-css'
import serve from 'rollup-plugin-serve'
import sourcemaps from 'rollup-plugin-sourcemaps2';
import fs from 'fs'
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
fs.copyFileSync('src/ViperIDE.html', 'build/index.html')
fs.copyFileSync('src/benchmark.html', 'build/benchmark.html')
fs.copyFileSync('src/bridge.html', 'build/bridge.html')
const common = (args, name) => ({
output: {
name,
dir: 'build',
format: 'iife',
indent: false,
sourcemap: args.configDebug,
},
context: 'window',
onwarn: (warning, _warn) => {
throw new Error(warning.message)
},
plugins: [
css({
output: `${name}.css`,
minify: !args.configDebug,
}),
resolve(),
commonjs(),
json({
compact: true
}),
replace({
preventAssignment: true,
values: {
VIPER_IDE_VERSION: '"' + pkg.version + '"',
VIPER_IDE_BUILD: Date.now(),
}
}),
args.configDebug && sourcemaps(),
!args.configDebug && terser(),
args.configDebug && serve("build"),
]
})
export default args => [{
input: './src/app.js',
...common(args, 'app')
},{
input: './src/viper_lib.js',
...common(args, 'viper_lib')
},{
input: './src/app_worker.js',
...common(args, 'app_worker')
}]