forked from AlaskaAirlines/auro-card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
75 lines (69 loc) · 1.84 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
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: {
['auro-card__bundled']: './src/auro-card.js',
['auro-banner__bundled']: './src/auro-banner.js'
},
output: {
format: 'esm',
dir: 'dist/'
},
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 cardConfig = {
input: 'src/es5.js',
output: {
format: 'iife',
file: 'dist/auro-card__bundled.es5.js'
},
plugins: getSharedPlugins(true)
};
const bannerConfig = {
input: 'src/es5.js',
output: {
format: 'iife',
file: 'dist/auro-banner__bundled.es5.js'
},
plugins: getSharedPlugins(true)
};
export default [modernConfig, cardConfig, bannerConfig];