Repository navigation
Expand file tree
/
Copy pathrolldown.config.ts
More file actions
95 lines (88 loc) · 2.66 KB
/
Copy pathrolldown.config.ts
File metadata and controls
95 lines (88 loc) · 2.66 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { createRequire } from 'node:module';
import path from 'node:path';
import process from 'node:process';
import { defineConfig } from 'rolldown';
// rolldown plugins
import nodePolyfills from '@rolldown/plugin-node-polyfills';
// rollup plugins
import copy from 'rollup-plugin-copy';
import css from './scripts/rollup-plugin-css.mjs';
// Resolve the codicons dist dir via Node resolution so it works regardless of
// pnpm hoisting (avoids a hard-coded node_modules path).
const nodeRequire = createRequire(import.meta.url);
const codiconsDist = path.dirname(nodeRequire.resolve('@vscode/codicons/dist/codicon.css'));
const production = process.env.NODE_ENV === 'production';
export default defineConfig([
{
input: './lana/src/Main.ts',
output: {
format: 'esm',
dir: './lana/out',
// Not cleanDir: a watch rebuild of this config alone would delete the viewer
// bundle and codicons that later configs write into the same directory.
cleanDir: false,
chunkFileNames: 'lana-[name].js',
sourcemap: false,
keepNames: true,
minify: production,
},
tsconfig: production ? './lana/tsconfig.json' : './lana/tsconfig-dev.json',
platform: 'node',
external: ['vscode'],
},
{
input: { Main: './lana/src/Main.web.ts' },
output: {
format: 'cjs',
dir: './lana/out/web',
entryFileNames: 'Main.web.cjs',
// The web extension host resolves only require('vscode'), so a split
// bundle cannot load its own chunks.
codeSplitting: false,
sourcemap: false,
keepNames: true,
minify: production,
},
tsconfig: production ? './lana/tsconfig.json' : './lana/tsconfig-dev.json',
platform: 'browser',
external: ['vscode'],
plugins: [nodePolyfills()],
},
{
input: { bundle: './log-viewer/src/Main.ts' },
output: [
{
format: 'esm',
dir: './log-viewer/out',
cleanDir: true,
chunkFileNames: 'log-viewer-[name].js',
sourcemap: false,
keepNames: true,
minify: production,
},
],
platform: 'browser',
moduleTypes: {
'.css': 'js',
'.scss': 'js',
},
tsconfig: production ? './log-viewer/tsconfig.json' : './log-viewer/tsconfig-dev.json',
plugins: [
nodePolyfills(),
css({ minify: production }),
copy({
hook: 'closeBundle',
targets: [
{
src: ['log-viewer/out/*', 'log-viewer/index.html', 'lana/certinia-icon-color.png'],
dest: 'lana/out',
},
{
src: path.join(codiconsDist, 'codicon.{css,ttf}'),
dest: 'lana/out',
},
],
}),
],
},
]);