-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
executable file
·78 lines (68 loc) · 1.76 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
import typescript from '@rollup/plugin-typescript';
import copy from 'rollup-plugin-copy';
import replace from '@rollup/plugin-replace';
import pjson from './package.json';
const production = process.env.BUILD === 'production';
const config = [];
const inputs = [
'background.ts',
'toolbar.ts',
'options.ts',
'content.ts',
'sites/hasznaltauto.hu.ts',
'sites/ingatlan.com.ts',
'sites/ingatlan.jofogas.hu.ts',
'sites/mobile.de.ts',
'sites/immobilienscout24.de.ts',
];
const rootDir = production ? 'build' : 'build-dev';
const commonPlugins = [
typescript(),
replace({
__buildEnv__: JSON.stringify(production ? 'production' : 'development'),
__buildVersion__: JSON.stringify(pjson.version)
})
];
for (const input of inputs) {
if (!production && input === 'background.ts') {
config.push({
input: `src/background-dev.ts`,
output: [
{
file: 'build-dev/background.js',
format: 'iife'
}
],
plugins: [
...commonPlugins
]
});
continue;
}
config.push({
input: `src/${input}`,
output: [
{
dir: `${rootDir}${input.indexOf('sites/') === 0 ? '/sites' : ''}`,
format: 'iife'
}
],
plugins: [
...commonPlugins
]
});
}
config[0].plugins.push(copy({
targets: [
{ src: `assets/${production ? 'icons' : 'icons-dev'}/*`, dest: `${rootDir}/icons` },
{ src: `assets/_locales/*`, dest: `${rootDir}/_locales` },
{ src: 'assets/options.html', dest: rootDir },
{ src: 'assets/htm-preact-3.0.4-standalone.umd.js', dest: rootDir },
{
src: 'assets/manifest.json',
dest: rootDir,
transform: (contents) => contents.toString().replace('__VERSION__', pjson.version)
}
]
}));
export default config;