Skip to content

Commit

Permalink
fix vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisShank committed Dec 12, 2024
1 parent 2fccf42 commit 3623702
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion demo/projector.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
});

document.addEventListener('click', (event) => {
console.log(event.target);
if (event.target === document.body || event.target === projector) {
projector.project();
}
Expand Down
17 changes: 10 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import { defineConfig, IndexHtmlTransformContext, Plugin } from 'vite';

const demoDir = resolve(__dirname, 'demo');

const files: string[] = readdirSync(demoDir).filter((file) => file.endsWith('.html'));
const input: Record<string, string> = files.reduce((acc, file) => {
acc[file.replace('.html', '')] = resolve(demoDir, file);
return acc;
}, {} as Record<string, string>);
function getFiles() {
return readdirSync(demoDir).filter((file) => file.endsWith('.html'));
}

const linkGenerator = (): Plugin => {
return {
name: 'link-generator',
transformIndexHtml(html: string, ctx: IndexHtmlTransformContext) {
if (!ctx.filename.endsWith('index.html')) return;

const files = getFiles();
// First, handle ungrouped files
const ungroupedFiles = files.filter(
(file) => !file.includes('index') && !file.startsWith('_') && !file.match(/^\[([^\]]+)\]/)
Expand Down Expand Up @@ -70,7 +68,12 @@ export default defineConfig({
plugins: [linkGenerator()],
build: {
target: 'esnext',
rollupOptions: { input },
rollupOptions: {
input: getFiles().reduce((acc, file) => {
acc[file.replace('.html', '')] = resolve(demoDir, file);
return acc;
}, {} as Record<string, string>),
},
modulePreload: {
polyfill: false,
},
Expand Down

0 comments on commit 3623702

Please sign in to comment.