| 33 | // Loads `./styles.css?inline` as a string, as Vite does in the tests. The CSS |
| 34 | // is not minified by the JS minifier, so remove comments and extra whitespace. |
| 35 | const inlineCss = () => ({ |
| 36 | name: 'inline-css', |
| 37 | resolveId(id: string, importer?: string) { |
| 38 | if (id.endsWith('.css?inline') && importer) { |
| 39 | return resolve(dirname(importer), id) |
| 40 | } |
| 41 | return undefined |
| 42 | }, |
| 43 | load(id: string) { |
| 44 | if (!id.endsWith('.css?inline')) return undefined |
| 45 | const css = readFileSync(id.slice(0, -'?inline'.length), 'utf8') |
| 46 | .replace(/\/\*[\s\S]*?\*\//g, '') |
| 47 | .replace(/\s+/g, ' ') |
| 48 | .replace(/ ?([{};]) ?/g, '$1') |
| 49 | .trim() |
| 50 | return { code: `export default ${JSON.stringify(css)}`, moduleType: 'js' } |
| 51 | }, |
| 52 | }) |
| 53 | |
| 54 | const baseConfig: UserConfig = { |
| 55 | target: 'esnext', |