-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrollup.config.js
74 lines (71 loc) · 2.31 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
import { defineConfig } from 'rollup';
import copy from 'rollup-plugin-copy'
// Let Rollup know that these libraries are known and it should not complain about them,
const externalImports = [
'gi://St',
'gi://GLib',
'gi://Gio',
'gi://Gtk',
'gi://GObject',
'gi://Clutter',
'resource:///org/gnome/shell/ui/main.js',
'resource:///org/gnome/shell/ui/panelMenu.js',
'resource:///org/gnome/shell/ui/popupMenu.js',
'resource:///org/gnome/shell/ui/modalDialog.js',
'gi://Meta',
'gi://Shell',
'gi://Adw',
'resource:///org/gnome/shell/extensions/extension.js',
'resource:///org/gnome/shell/misc/config.js',
'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'
]
export default defineConfig([
{
input: "build/app.js",
output: {
file: "dist/extension.js",
esModule: true,
},
plugins: [
stripExports(),
],
external: externalImports
},
{
input: "build/prefs_builder.js",
output: {
file: "dist/prefs.js",
esModule: true,
},
plugins: [
stripExports(),
copy({
targets: [
{ src: 'LICENSE', dest: 'dist/' },
{ src: 'src/metadata.json', dest: 'dist/' },
{ src: 'src/layouts-default.json', dest: 'dist/' },
{ src: 'src/stylesheet.css', dest: 'dist/' },
{ src: 'src/images', dest: 'dist/' },
{ src: 'src/schemas/gschemas.compiled', dest: 'dist/schemas' },
{ src: 'src/schemas/org.gnome.shell.extensions.gsnap.gschema.xml', dest: 'dist/schemas' },
]
})
],
external: externalImports
}
]);
// Cleans up the generated bundle from lines like exports.XXXX
// This trick is a compromise between using the tree-shaker and
// still have functions that must not be cleaned up (such as
// the extension's enable/disable entrypoints). To let those
// functions live in the tree-shaken bundle, simply declare them
// as exported.
function stripExports() {
return {
name: 'strip-exports',
renderChunk(code) {
const re = /^exports\.\w+.*(\n|\r\n|)/gm;
return code.replace(re, '');
}
};
}