-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
81 lines (76 loc) · 2.35 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
81
require('dotenv').config();
import createDefaultConfig from '@open-wc/building-rollup/modern-and-legacy-config';
import replace from "rollup-plugin-replace";
import nodeResolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';
import typescript from 'rollup-plugin-typescript2';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import litcss from 'rollup-plugin-lit-css';
import cpy from 'rollup-plugin-cpy';
import workbox from 'rollup-plugin-workbox-build';
import liveServer from 'rollup-plugin-live-server';
const inProd = process.env.BUILD === 'production';
const mapEnvVars = vars => vars.reduce((res, envVar) => {
res[envVar] = process.env[envVar];
return res;
}, {});
const configs = createDefaultConfig({
input: './index.html',
outputDir: 'dist',
});
const once = (index, plugins) => index === 0 ? plugins : [];
export default configs.map((config, i) => ({
...config,
plugins: [
replace(mapEnvVars([
'CONTENTFUL_SPACE_ID',
'CONTENTFUL_ACCESS_TOKEN',
'CONTENTFUL_MANAGEMENT_TOKEN',
'EVENTBRITE_ORG_ID',
'EVENTBRITE_TOKEN',
])),
config.plugins[0],
config.plugins[1],
builtins(),
nodeResolve({
browser: true,
}),
commonjs(),
json(),
litcss(),
config.plugins[3],
typescript(),
config.plugins[4],
...once(i, [
inProd && cpy({
files: ['assets/**/*', 'manifest.json'],
dest: 'dist/',
options: {
parents: true,
},
}),
inProd && workbox({
mode: 'generateSW',
options: require('./workbox.config'),
}),
!inProd && liveServer({
port: 8200,
host: 'localhost',
root: 'dist',
file: 'index.html',
mount: [
['/dist', './dist'],
['/node_modules', './node_modules'],
['/assets', './assets'],
['/manifest.json', './manifest.json'],
],
open: false,
wait: 200,
}),
]),
],
watch: {
clearScreen: false
},
}));