forked from gdg-x/hoverboard
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.ts
80 lines (77 loc) · 2.06 KB
/
rollup.config.ts
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
/* eslint-env node */
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import { rollupPluginHTML as html } from '@web/rollup-plugin-html';
import fs from 'fs';
import { RollupOptions } from 'rollup';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import { generateSW } from 'rollup-plugin-workbox';
import { compileBufferTemplate, production, watch } from './utils/build';
import { workboxConfig } from './workbox.config';
const config: RollupOptions[] = [
{
input: 'src/firebase-messaging-sw.ts',
treeshake: production,
output: {
file: 'dist/firebase-messaging-sw.js',
sourcemap: production,
},
plugins: [
nodeResolve(),
typescript({
noEmitOnError: true,
sourceMap: production,
}),
production && terser(),
],
},
{
treeshake: production,
output: {
dir: 'dist',
entryFileNames: production ? '[name]-[hash].js' : '[name].js',
chunkFileNames: production ? '[name]-[hash].js' : '[name].js',
sourcemap: production,
},
plugins: [
nodeResolve(),
json(),
typescript({
noEmitOnError: true,
sourceMap: production,
}),
html({
input: {
html: compileBufferTemplate(fs.readFileSync('index.html')),
},
extractAssets: false,
minify: production,
}),
copy({
targets: [
{
src: 'public/*',
dest: 'dist',
},
{
src: 'public/manifest.json',
dest: 'dist',
transform: compileBufferTemplate,
},
{
src: 'public/data/*.md',
dest: 'dist/data',
transform: compileBufferTemplate,
},
],
}),
production && generateSW(workboxConfig),
production && terser(),
watch && livereload({ watch: 'dist' }),
],
},
];
export default config;