This repository was archived by the owner on Nov 14, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
74 lines (66 loc) · 2.22 KB
/
Copy pathrollup.config.mjs
File metadata and controls
74 lines (66 loc) · 2.22 KB
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 svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import css from 'rollup-plugin-import-css';
import postcss from 'postcss';
import autoprefixer from 'autoprefixer';
import { readFileSync } from 'fs';
async function transformStyles(content) {
const result = await postcss([autoprefixer]).process(content, { from: undefined });
return { code: result.css };
}
function webviewRollupConfig(name) {
return {
input: `media/unprocessed/${name}.js`,
output: {
sourcemap: true,
name: 'app',
file: `media/rolled-up/${name}.js`,
format: 'iife',
},
plugins: [
css({
output: `${name}.svelte.css`,
alwaysOutput: true,
minify: true,
}),
svelte({
include: `src/webview-providers/${name}/**/*.{svelte,ts}`,
preprocess: {
style: async ({ content }) => {
return transformStyles(content);
},
},
emitCss: true,
onwarn: (warning, handler) => {
if (warning.code === 'a11y-distracting-elements') return;
handler(warning);
},
compilerOptions: {
hydratable: true,
customElement: false,
},
}),
resolve({
browser: true,
exportConditions: ['svelte', '.ts'],
extensions: ['.svelte', '.ts'],
dedupe: ['svelte', '.ts'],
}),
],
};
}
/*
*
* Read the package.json to find out the differen webviews that exist
*
*/
function getConfig() {
const extensionPackageJson = JSON.parse(readFileSync('package.json').toString());
const webviews = extensionPackageJson['contributes']['views']['explorer'];
// Make this conversion: aderyn.webview-providers.onboard-panel => onboard-panel
return webviews
.filter((view) => view['type'] == 'webview')
.map((view) => view.id.split('.')[2])
.map((name) => webviewRollupConfig(name));
}
export default getConfig();