forked from zoom/zoomapps-sample-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
92 lines (86 loc) · 2.07 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
import { babel } from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import copy from 'rollup-plugin-copy';
import del from 'rollup-plugin-delete';
const production =
process.env.NODE_ENV === 'production' && !process.env.ROLLUP_WATCH;
const src = 'public';
const dest = 'dist';
const name = 'bundle';
const input = `${src}/js/index.js`;
const out = `${dest}/js/${name}`;
const plugins = [
resolve({
browser: true,
}),
commonjs(),
del({ targets: `${dest}}/*` }),
copy({
targets: [
{
src: `${src}/js/vendor/*`,
dest: `${dest}/js/vendor`,
},
{
src: `${src}/{css,img}`,
dest,
},
],
}),
babel({
babelrc: false,
babelHelpers: 'runtime',
exclude: [
/node_modules/,
/core-js/, //https://github.com/rollup/rollup-plugin-babel/issues/254
],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers:
'> 0.25%, last 4 major versions, not dead, not ie 11',
},
corejs: 3,
useBuiltIns: 'usage',
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
],
}),
production && terser(),
];
export default [
{
input,
plugins,
output: [
{
file: `${out}.js`,
format: 'iife',
sourcemap: true,
},
],
},
{
input,
plugins,
output: [
{
file: `${out}.mjs`,
format: 'module',
sourcemap: true,
},
],
},
];