-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
rollup.config.js
41 lines (39 loc) · 1 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
import { terser } from 'rollup-plugin-terser';
import del from 'rollup-plugin-delete';
import { generateSW } from 'rollup-plugin-workbox';
import sizes from 'rollup-plugin-sizes';
import css from 'rollup-plugin-css-only';
const isProd = process.env.NODE_ENV === 'production';
export default {
input: ['src/js/index.js'],
output: [
{
file: 'public/bundle.js',
format: 'cjs',
assetFileNames: '[name]-[hash][extname]',
},
],
plugins: [
del({ targets: ['public/workbox-*.js', 'public/sw.js', 'public/bundle.js', 'public/bundle.css'] }),
css({ output: 'bundle.css' }),
terser(),
isProd &&
generateSW({
swDest: 'public/service-worker.js',
globDirectory: './public',
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: isProd ? /https:\/\/qrcodescan.in\// : /http:\/\/localhost:5000\//,
handler: 'CacheFirst',
options: {
cacheName: 'pages',
cacheableResponse: { statuses: [200] },
},
},
],
}),
sizes(),
],
};