Skip to content

Commit

Permalink
Add configuration for netlify builds to include demo files.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 27, 2024
1 parent 30d4ee8 commit cdcacd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

[[redirects]]
from = "/"
to = "/__tests__/integration/mirador/"
to = "/dist/__tests__/integration/mirador/"
17 changes: 16 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import fs from 'fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'url';
import { globSync } from 'fs';

/**
* Vite configuration
Expand All @@ -11,11 +13,24 @@ export default defineConfig({
lib: {
entry: './src/index.js',
fileName: (format) => (format === 'umd' ? 'mirador.js' : 'mirador.es.js'),
formats: ['es', 'umd'],
formats: process.env.NETLIFY ? ['es'] : ['es', 'umd'],
name: 'Mirador',
},
rollupOptions: {
external: ['__tests__/*', '__mocks__/*'],
input: process.env.NETLIFY ? Object.fromEntries(
globSync('./__tests__/integration/mirador/*.html').map((file) => [
// This remove `src/` as well as the file extension from each
// file, so e.g. src/nested/foo.js becomes nested/foo
path.relative(
'__tests__/integration/mirador',
file.slice(0, file.length - path.extname(file).length),
),
// This expands the relative paths to absolute paths, so e.g.
// src/nested/foo becomes /project/src/nested/foo.js
fileURLToPath(new URL(file, import.meta.url)),
]),
) : undefined,
output: {
assetFileNames: 'mirador.[ext]',
},
Expand Down

0 comments on commit cdcacd0

Please sign in to comment.