-
Notifications
You must be signed in to change notification settings - Fork 138
/
rollup.config.ts
79 lines (76 loc) · 2 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
/* eslint-env node */
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import html from '@web/rollup-plugin-html';
import fs from 'fs';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import { generateSW } from 'rollup-plugin-workbox';
import { compileBufferTemplate, production } from './utils/build';
import { workboxConfig } from './workbox.config';
const { ROLLUP_WATCH } = process.env;
export default [
{
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(),
ROLLUP_WATCH && livereload({ watch: 'dist' }),
],
},
];