-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
49 lines (47 loc) · 1.47 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 fs from 'fs';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
const info = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf8' }));
let licenseHeader = fs.readFileSync('license-header.txt', { encoding: 'utf8' });
licenseHeader = licenseHeader.replace('{{version}}', info.version);
licenseHeader = licenseHeader.replace('{{year}}', new Date().getFullYear());
export default {
input: 'src/element-behaviors.js',
plugins: [
json(),
// Prepend our license header to the top of the output files.
{
name: 'prepend-license',
generateBundle(options, bundle) {
for (const chunk of Object.values(bundle)) {
if (chunk.type === 'chunk') {
chunk.code = `${licenseHeader}\n${chunk.code}`;
}
}
}
}
],
output: [
// Compile uncompressed library; retains comments.
{
file: 'dist/eb.js',
format: 'iife'
},
// Compile and minified library (no comments) best for production.
{
file: 'dist/eb.min.js',
format: 'iife',
plugins: [
terser()
]
},
// Compile and minified library for demo site.
{
file: 'www/js/eb.min.js',
format: 'iife',
plugins: [
terser()
]
},
]
};