forked from riju/WebCamera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
80 lines (73 loc) · 2.2 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
const resolve = require('rollup-plugin-node-resolve');
const babel = require('rollup-plugin-babel');
const { terser } = require('rollup-plugin-terser');
const { DEFAULT_EXTENSIONS } = require('@babel/core');
const { findSupportedBrowsers } = require('@open-wc/building-utils');
const customMinifyCss = require('@open-wc/building-utils/custom-minify-css');
const production = !process.env.ROLLUP_WATCH;
const plugins = [
resolve(),
// run code through babel
babel({
extensions: DEFAULT_EXTENSIONS,
plugins: [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
// rollup rewrites import.meta.url, but makes them point to the file location after bundling
// we want the location before bundling
'bundled-import-meta',
production && [
'template-html-minifier',
{
modules: {
'lit-html': ['html'],
'lit-element': ['html', { name: 'css', encapsulation: 'style' }],
},
htmlMinifier: {
collapseWhitespace: true,
removeComments: true,
caseSensitive: true,
minifyCSS: customMinifyCss,
},
},
],
].filter(_ => !!_),
presets: [
[
'@babel/preset-env',
{
targets: findSupportedBrowsers(),
// preset-env compiles template literals for safari 12 due to a small bug which
// doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
exclude: ['@babel/plugin-transform-template-literals'],
useBuiltIns: false,
modules: false,
},
],
],
}),
// only minify if in production
production && terser()
];
const outputOptions = [
{
input: './elements/camera-capture/camera-capture.js',
output: {
file: './build/elements/camera-capture.js',
sourcemap: true,
format: 'esm',
name: 'CameraCapture'
},
plugins
},{
input: './elements/demo-logger/demo-logger.js',
output: {
file: './build/elements/demo-logger.js',
sourcemap: true,
format: 'esm',
name: 'CameraCapture'
},
plugins
}
];
export default outputOptions;