forked from RocketChat/Rocket.Chat.Electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
95 lines (89 loc) · 1.81 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
85
86
87
88
89
90
91
92
93
94
95
import builtinModules from 'builtin-modules';
import glob from 'glob';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import copy from 'rollup-plugin-copy';
import json from 'rollup-plugin-json';
import nodeResolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import appManifest from './package.json';
const NODE_ENV = process.env.NODE_ENV || 'development';
const bundleOptions = {
external: [
...builtinModules,
...Object.keys(appManifest.dependencies),
...Object.keys(appManifest.devDependencies),
],
plugins: [
copy({
targets: [
{ src: 'src/i18n/*.i18n.json', dest: 'app/i18n' },
{ src: 'src/public/*', dest: 'app/public' },
{ src: 'node_modules/@rocket.chat/icons/dist/*', dest: 'app/icons' },
],
}),
json(),
replace({
'process.env.BUGSNAG_API_KEY': JSON.stringify(process.env.BUGSNAG_API_KEY),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
babel(),
nodeResolve(),
commonjs(),
],
};
const createTestEntries = () => {
if (NODE_ENV !== 'test') {
return [];
}
const rendererSpecs = [
...glob.sync('src/**/*.spec.js'),
];
return [
...rendererSpecs.length
? [{
input: rendererSpecs,
...bundleOptions,
output: {
dir: 'app/renderer.specs',
format: 'cjs',
sourcemap: true,
},
}]
: [],
];
};
export default [
{
input: 'src/main.js',
...bundleOptions,
output: {
file: 'app/main.js',
format: 'cjs',
sourcemap: true,
},
},
{
input: 'src/app.js',
...bundleOptions,
output: [
{
file: 'app/app.js',
format: 'cjs',
sourcemap: true,
},
],
},
{
input: 'src/preload.js',
...bundleOptions,
output: [
{
file: 'app/preload.js',
format: 'cjs',
sourcemap: 'inline',
},
],
},
...createTestEntries(),
];