-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
84 lines (76 loc) · 2.06 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
82
83
84
// import {terser} from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import OMT from '@surma/rollup-plugin-off-main-thread';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from "@rollup/plugin-node-resolve";
import json from '@rollup/plugin-json';
const SRC_DIR = 'src';
const BUILD_DIR = 'dist';
export default {
input: `${SRC_DIR}/ziti-browzer-sw.ts`,
manualChunks: (id) => {
if (!id.includes('/node_modules/')) {
return undefined;
}
/**
* comment out the following IFF doing 'yarn link @openziti/ziti-browzer-sw-workbox-strategies' dev builds
*/
if (id.includes('/ziti-browzer-sw/node_modules/@openziti/ziti-browzer-core/')) {
return undefined;
}
const chunkNames = [
'/lodash-es/',
'/workbox-routing/',
'/libcrypto/',
'/ziti-browzer-core/',
'/ziti-browzer-sw-workbox-strategies/',
'/ziti-browzer-edge-client/',
'workbox-core',
'workbox-expiration',
'workbox-precaching',
'workbox-strategies',
'uuid',
];
// console.log('id is: ', id);
let res = chunkNames.find((chunkName) => id.includes(chunkName) ) || 'misc';
// console.log('res is: ', res);
let regex = /\//g;
res = res.replace(regex,'-');
return `ziti-browzer-sw-${res}`;
},
plugins: [
commonjs(),
json(),
nodeResolve({
preferBuiltins: false
}),
resolve({
preferBuiltins: false,
browser: true,
}),
replace({
'preventAssignment': true,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
}),
typescript(),
OMT(),
// workboxInjectManifest({
// globDirectory: BUILD_DIR,
// globPatterns: [
// '*.js',
// ],
// "globIgnores": [
// "**/node_modules/**/*",
// "*.map",
// ]
// }),
// terser(),
],
output: {
sourcemap: false,
format: 'amd',
dir: BUILD_DIR,
},
};