MCPcopy Create free account
hub / github.com/objectivehtml/FlipClock / writeBundle

Function writeBundle

vite.config.ts:36–66  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

34 return {
35 name: 'extract-css',
36 writeBundle(options) {
37 if (hasExtracted || !options.dir) {
38 return Promise.resolve();
39 }
40
41 const promises: Promise<void>[] = [];
42
43 for (const [filename, [css, selector]] of Object.entries(files)) {
44 const hash = String(css());
45 const extractedCss = extractCss();
46 const contents = extractedCss
47 .slice(lastExtractedLength)
48 .replaceAll(hash, selector);
49
50 const path = resolve(options.dir, 'themes');
51
52 promises.push(new Promise(async (res) => {
53 if (!await existsSync(path)) {
54 await mkdir(path);
55 }
56
57 res(writeFile(resolve(path, filename), contents));
58 }));
59
60 lastExtractedLength = extractedCss.length;
61 }
62
63 hasExtracted = true;
64
65 return Promise.all(promises).then();
66 }
67 };
68}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected