| 1 | import { resolve } from 'path'; |
| 2 | import { defineConfig } from 'vite'; |
| 3 | import fs from 'fs'; |
| 4 | |
| 5 | // List all theme files in the css/theme directory |
| 6 | const themeFiles = fs |
| 7 | .readdirSync(resolve(__dirname, 'css/theme')) |
| 8 | .filter((file) => file.endsWith('.scss')); |
| 9 | |
| 10 | const themeEntries = themeFiles.reduce((acc, file) => { |
| 11 | acc[`theme/${file.replace('.scss', '')}`] = resolve(__dirname, `css/theme/${file}`); |
| 12 | return acc; |
| 13 | }, {}); |
| 14 | |
| 15 | export default defineConfig({ |
| 16 | root: './', |
| 17 | css: { |
| 18 | preprocessorOptions: { |
| 19 | scss: { |
| 20 | api: 'modern-compiler', |
| 21 | }, |
| 22 | }, |
| 23 | }, |
| 24 | build: { |
| 25 | emptyOutDir: false, |
| 26 | cssCodeSplit: true, |
| 27 | lib: { |
| 28 | formats: ['es'], |
| 29 | entry: { |
| 30 | reveal: resolve(__dirname, 'css/reveal.scss'), |
| 31 | reset: resolve(__dirname, 'css/reset.css'), |
| 32 | |
| 33 | ...themeEntries, |
| 34 | }, |
| 35 | }, |
| 36 | }, |
| 37 | plugins: [], |
| 38 | }); |
| 39 |