vite.config.ts 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { resolve } from 'path';
  2. import { ModuleFormat } from 'rollup';
  3. import { defineConfig } from 'vite';
  4. import dts from 'vite-plugin-dts';
  5. export const appendExtension = (format: ModuleFormat, name: String): string => {
  6. if (format === 'es') {
  7. return `${name}.mjs`;
  8. } else {
  9. return `${name}.js`;
  10. }
  11. };
  12. export default defineConfig({
  13. build: {
  14. emptyOutDir: true,
  15. lib: {
  16. formats: ['es', 'umd'],
  17. entry: resolve(__dirname, 'js/index.ts'),
  18. name: 'Reveal',
  19. fileName: (format, entryName) => {
  20. return appendExtension(format, 'reveal');
  21. },
  22. },
  23. rollupOptions: {
  24. output: {
  25. assetFileNames: 'reveal.[ext]',
  26. },
  27. },
  28. },
  29. resolve: {
  30. alias: {
  31. // Matches the exported paths in package.json
  32. 'reveal.js/plugin': '/plugin',
  33. 'reveal.js': '/js',
  34. 'reveal.css': '/css/reveal.scss',
  35. },
  36. },
  37. plugins: [dts({ insertTypesEntry: true, rollupTypes: true })],
  38. css: {
  39. preprocessorOptions: {
  40. scss: {
  41. api: 'modern-compiler',
  42. },
  43. },
  44. },
  45. });