-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
54 lines (50 loc) · 1.12 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
import * as path from 'path';
import * as fs from 'fs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import pkg from './package.json';
const license = fs.readFileSync(path.resolve('LICENSE'), 'utf-8');
const bannerLines = [];
bannerLines.push('/*!');
bannerLines.push(` * ${pkg.name} v${pkg.version}`);
bannerLines.push(' *');
license.split(/\r?\n/).forEach((line) => {
bannerLines.push(` * ${line}`);
});
bannerLines.push(' */');
const banner = bannerLines.join('\n');
const errors = fs.readFileSync(path.resolve('./errors.json'), 'utf-8');
export default {
input: 'src/index.js',
plugins: [
replace({
delimiters: ["'", "'"],
values: {
ERRORS: errors,
},
}),
babel({
babelrc: false,
plugins: [
[
'@babel/plugin-proposal-object-rest-spread',
{ useBuiltIns: true },
],
],
}),
],
output: [
{
file: 'build/index.js',
format: 'cjs',
sourcemap: true,
banner,
},
{
file: 'build/index.es.js',
format: 'es',
sourcemap: true,
banner,
},
],
};