forked from AlaskaAirlines/auro-header
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
63 lines (58 loc) · 1.6 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
import { terser } from 'rollup-plugin-terser';
import alias from '@rollup/plugin-alias';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import minifyHTML from 'rollup-plugin-minify-html-literals';
import resolve from '@rollup/plugin-node-resolve';
import serve from 'rollup-plugin-serve';
const production = !process.env.ROLLUP_WATCH;
const getSharedPlugins = (isLegacy) => [
resolve({
// in case of multiple lit-element versions (e.g. importing another auro component)
dedupe: ['lit-element', 'lit-html']
}),
commonjs(),
// skipPreflightCheck flag needed or else build fails
// see https://github.com/rollup/plugins/issues/381
babel({
babelHelpers: 'bundled',
envName: isLegacy ? 'legacy' : 'modern',
skipPreflightCheck: true
}),
minifyHTML(),
terser()
];
const modernConfig = {
input: 'index.js',
output: {
format: 'esm',
file: 'dist/auro-header__bundled.js'
},
plugins: [
// remove shady DOM polyfill for modern browsers
// https://lit-element.polymer-project.org/guide/build#compile-out-the-shady-render-module
alias({
entries: [
{
find: 'lit-html/lib/shady-render.js',
replacement: 'node_modules/lit-html/lit-html.js'
}
]
}),
...getSharedPlugins(false),
!production &&
serve({
open: true,
openPage: '/docs/'
})
]
};
const legacyConfig = {
input: 'src/es5.js',
output: {
format: 'iife',
file: 'dist/auro-header__bundled.es5.js'
},
plugins: getSharedPlugins(true)
};
export default [modernConfig, legacyConfig];