forked from GnomeSnapExtensions/gSnap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
54 lines (52 loc) · 1.66 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
import { defineConfig } from 'rollup';
import copy from 'rollup-plugin-copy'
export default defineConfig([
{
input: "build/app.js",
output: {
file: "dist/extension.js",
format: "cjs",
esModule: false,
},
plugins: [
stripExports(),
]
},
{
input: "build/prefs_builder.js",
output: {
file: "dist/prefs.js",
format: "cjs",
esModule: false,
},
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' },
]
})
]
}
]);
// 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, '');
}
};
}