-
Notifications
You must be signed in to change notification settings - Fork 15
/
rollup.config.js
79 lines (71 loc) · 1.86 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
import path from 'path';
import fs from 'fs';
import cleanup from 'rollup-plugin-cleanup';
//import getBabelOutputPlugin from '@rollup/plugin-babel';
import terser from "@rollup/plugin-terser";
import json from '@rollup/plugin-json';
import jscc from 'rollup-plugin-jscc';
// Parse the version information from the current module.json
import { _parse_manifest_version } from './src/shared/version.js';
import moduleJson from './module.json' assert {type: 'json'};
const pkgVersion = _parse_manifest_version(moduleJson.version, moduleJson.flags.git_version);
if(!pkgVersion.known)
throw "Failed to parse package version";
// Get a list of the available languages, to pass to JSCC
const i18nLangs = fs.readdirSync('./lang').map((f) => path.parse(f).name);
// Rollup config
export default {
strictDeprecations: true,
input: 'src/index.js',
output: {
file: 'dist/lib-wrapper.js',
format: 'es',
globals: {
jquery: '$'
},
banner: "// SPDX-License-Identifier: LGPL-3.0-or-later\n// Copyright © 2021 fvtt-lib-wrapper Rui Pinheiro\n",
compact: true,
interop: false,
sourcemap: 'dist/lib-wrapper.js.map',
sourcemapPathTransform: (nm) => {
// Dirname
const dirname = path.relative('../', path.dirname(nm)); // Ensure paths are relative to the repository folder, not to 'dist'
// Basename
let basename = path.basename(nm);
if(basename != 'listeners.js')
basename = 'libWrapper-' + basename;
// Join together
return path.join(dirname, basename);
}
},
plugins: [
jscc({
values: {
_ROLLUP: 1,
_PACKAGE_VERSION: pkgVersion,
_I18N_LANGS: i18nLangs
}
}),
json({
compact: true
}),
cleanup({
comments: 'jsdoc'
}),
/*getBabelOutputPlugin({
plugins: [
]
}),*/
terser({
ecma: 2021,
toplevel: true,
module: true,
keep_classnames: true,
/*mangle: {
properties: {
regex: /^_/
}
}*/
})
]
};