MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / min

Function min

packages/tooling/src/vite.plugin.min.ts:6–34  ·  view source on GitHub ↗
(options: MinifyOptions)

Source from the content-addressed store, hash-verified

4import { type MinifyOptions, minify } from 'terser';
5
6export default function min(options: MinifyOptions): OutputPlugin {
7 return {
8 name: 'min',
9 async writeBundle(opts, bundle) {
10 const files = Object.keys(bundle);
11
12 for (const file of files) {
13 const chunk = bundle[file];
14 if ((file.endsWith('.mjs') || file.endsWith('.js')) && chunk.type === 'chunk' && chunk.isEntry) {
15 this.info(`Creating min file for bundle ${file}`);
16
17 const o = { ...options };
18 if (opts.format === 'es') {
19 o.module = true;
20 } else if (opts.format === 'cjs') {
21 o.toplevel = true;
22 }
23
24 const min = await minify(chunk.code, o);
25 const outputFile = path.resolve(
26 opts.dir!,
27 file.replace('.mjs', '.min.mjs').replace('.js', '.min.js')
28 );
29 await fs.promises.writeFile(outputFile, min.code!);
30 }
31 }
32 }
33 };
34}

Callers 4

readMethod · 0.85
writeSamplesMethod · 0.85
umdFunction · 0.85
esmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected