Skip to content

Commit 1fbb439

Browse files
committed
chore: compile to a single file to support vscode web extension
close #64
1 parent f804a75 commit 1fbb439

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

rollup.config.mjs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,38 @@ function definePlugins(options) {
6767
].filter(Boolean);
6868
}
6969

70+
const { packageJson } = await readPackageUp();
7071
const isProd = process.env.NODE_ENV === 'production';
7172
const replaceValues = {
7273
'process.env.TOOLBAR_VERSION': JSON.stringify(
73-
await getVersion('markmap-toolbar'),
74+
await getVersion('markmap-toolbar')
7475
),
7576
};
7677
const external = defineExternal(['path', 'vscode']);
7778

7879
export default defineConfig([
7980
{
8081
input: {
82+
app: 'src/app.ts',
83+
},
84+
plugins: definePlugins({
85+
replaceValues,
86+
}),
87+
external: ['markmap-toolbar', 'markmap-view'],
88+
output: {
89+
format: 'iife',
90+
dir: 'dist',
91+
globals: {
92+
'markmap-common': 'markmap',
93+
'markmap-toolbar': 'markmap',
94+
'markmap-view': 'markmap',
95+
},
96+
},
97+
},
98+
{
99+
input: {
100+
// Must build separately because VSCode web extension only accepts a single file
81101
extension: 'src/extension.ts',
82-
postbuild: 'src/postbuild.ts',
83102
},
84103
plugins: definePlugins({
85104
replaceValues,
@@ -92,20 +111,18 @@ export default defineConfig([
92111
},
93112
{
94113
input: {
95-
app: 'src/app.ts',
114+
postbuild: 'src/postbuild.ts',
96115
},
97116
plugins: definePlugins({
98117
replaceValues,
99118
}),
100-
external: ['markmap-toolbar', 'markmap-view'],
119+
external: defineExternal([
120+
'path',
121+
...Object.keys(packageJson.devDependencies),
122+
]),
101123
output: {
102-
format: 'iife',
124+
format: 'cjs',
103125
dir: 'dist',
104-
globals: {
105-
'markmap-common': 'markmap',
106-
'markmap-toolbar': 'markmap',
107-
'markmap-view': 'markmap',
108-
},
109126
},
110127
},
111128
]);

0 commit comments

Comments
 (0)