// src/waves.css -> dist/waves.css with the texture inlined as a data URI, // so consumers get one file and no asset paths for their bundler to resolve. import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; const src = new URL('../src/', import.meta.url); const dist = new URL('../dist/', import.meta.url); const css = readFileSync(new URL('waves.css', src), 'utf8').replace( /url\('\.\/([^']+)\.png'\)/g, (_, name) => `url('data:image/png;base64,${readFileSync(new URL(`${name}.png`, src)).toString('base64')}')`, ); if (css.includes("url('./")) throw new Error('src/waves.css references a file that was not inlined'); mkdirSync(dist, { recursive: true }); writeFileSync(new URL('waves.css', dist), css); console.log(`dist/waves.css: ${(css.length / 1024).toFixed(1)} KiB`);