This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrollup.config.js
63 lines (60 loc) · 1.83 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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import resolve from "@rollup/plugin-node-resolve";
/**
* Helper to detect developer mode.
*
* @param cliArgs the command line arguments.
* @return {Boolean} whether or not developer mode is enabled.
*/
function isDevMode(cliArgs) {
return Boolean(cliArgs["config-enable-developer-mode"]);
}
export default (cliArgs) => [
{
input: "src/main.js",
output: {
file: "dist/background.js",
sourcemap: isDevMode(cliArgs) ? "inline" : false,
},
plugins: [
replace({
// In Developer Mode, the study does not submit data and
// gracefully handles communication errors with the Core
// Add-on.
__ENABLE_DEVELOPER_MODE__: isDevMode(cliArgs),
}),
resolve({
browser: true,
// These are required in order for rollup to pick up
// the correct dependencies for ping encryption.
exportConditions: ["browser"],
preferBuiltins: false,
}),
commonjs(),
],
},
{
input: "src/content-scripts/attention-collector.js",
output: {
file: "dist/content-scripts/attention-collector.js",
sourcemap: isDevMode(cliArgs) ? "inline" : false,
},
plugins: [
replace({
// In Developer Mode, the study does not submit data and
// gracefully handles communication errors with the Core
// Add-on.
__ENABLE_DEVELOPER_MODE__: isDevMode(cliArgs),
}),
resolve({
browser: true,
}),
commonjs(),
],
}
// NOTE: a content script rollup is not needed for this study.
];