forked from cloudbuy/modheader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
73 lines (71 loc) · 2.2 KB
/
rollup.config.mjs
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
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import zip from 'rollup-plugin-zip';
import svelte from 'rollup-plugin-svelte';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import cssModules from 'svelte-preprocess-cssmodules';
import { chromeExtension, simpleReloader } from 'rollup-plugin-chrome-extension';
import { emptyDir } from 'rollup-plugin-empty-dir';
const production = !process.env.ROLLUP_WATCH;
const URL_BASE = production
? 'https://modheader.com'
: process.env.URL_BASE || 'https://modheader.com';
export default {
input: 'src/manifest.json',
output: {
dir: 'dist',
format: 'esm'
},
plugins: [
replace({
preventAssignment: true,
'process.env.PROFILE_TYPE': JSON.stringify('ModHeader'),
'process.env.PRODUCT_NAME': JSON.stringify('ModHeader'),
'process.env.BROWSER': JSON.stringify(process.env.BROWSER),
'process.env.URL_BASE': JSON.stringify(URL_BASE)
}),
chromeExtension({
extendManifest: (manifest) => {
if (!production) {
manifest.externally_connectable.matches.push('*://localhost/*');
}
if (process.env.BROWSER === 'firefox') {
manifest.content_scripts = [
{
matches: [production ? 'https://modheader.com/*' : 'http://localhost/*'],
js: ['js/native-messaging.js']
}
];
manifest.browser_specific_settings = {
gecko: {
id: '{ed630365-1261-4ba9-a676-99963d2b4f54}',
strict_min_version: '75.0'
}
};
}
return manifest;
}
}),
simpleReloader(),
svelte({
preprocess: [cssModules()],
compilerOptions: {
dev: !production
},
emitCss: false
}),
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
// https://github.com/rollup/plugins/tree/master/packages/commonjs
// Empties the output dir before a new build
emptyDir(),
// If we're building for production, minify
production && terser(),
// Outputs a zip file in ./releases
production && zip({ dir: 'releases' })
]
};