forked from Forien/foundryvtt-forien-quest-log
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrollup.config.js
68 lines (61 loc) · 1.91 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
import path from 'node:path';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser'; // Terser is used for minification / mangling
import virtual from '@rollup/plugin-virtual';
// Terser config; refer to respective documentation for more information.
const terserConfig = {
compress: { passes: 3 },
mangle: { toplevel: true, keep_classnames: true, keep_fnames: true },
ecma: 2021,
module: true
};
// The deploy path for the server bundle which includes the common code.
const s_DEPLOY_PATH = './external';
const s_DEPLOY_MINIFY = true;
// Produce sourcemaps or not
const s_SOURCEMAP = true;
// Defines potential output plugins to use conditionally if the .env file indicates the bundles should be
// minified / mangled.
const outputPlugins = [];
if (s_DEPLOY_MINIFY)
{
outputPlugins.push(terser(terserConfig));
}
export default () =>
{
return [
{
input: 'pack',
output: [{
file: `${s_DEPLOY_PATH}${path.sep}collect.js`,
format: 'es',
plugins: outputPlugins,
generatedCode: { constBindings: true },
sourcemap: s_SOURCEMAP,
}],
plugins: [
virtual({
pack: `export { collect as default } from './node_modules/collect.js/src/index.js';`
}),
resolve({ browser: true }),
commonjs()
]
},
{
input: 'pack',
output: [{
file: `${s_DEPLOY_PATH}${path.sep}DOMPurify.js`,
format: 'es',
plugins: outputPlugins,
generatedCode: { constBindings: true },
sourcemap: s_SOURCEMAP,
}],
plugins: [
virtual({
pack: `export { default } from './node_modules/dompurify/dist/purify.es.mjs';`
})
]
}
];
};