(options)
| 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected