Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlify #4009

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Netlify #4009

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This is the configuration file for the netlify preview deploys
# See https://www.netlify.com/docs/netlify-toml-reference/ for more

[build]
publish = "dist/"

[[redirects]]
from = "/"
to = "/__tests__/integration/mirador/"
54 changes: 40 additions & 14 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
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 'glob';

/**
* Vite configuration
*/
export default defineConfig({
build: {
lib: {
entry: './src/index.js',
fileName: (format) => (format === 'umd' ? 'mirador.js' : 'mirador.es.js'),
formats: ['es', 'umd'],
name: 'Mirador',
},
rollupOptions: {
external: ['__tests__/*', '__mocks__/*'],
output: {
assetFileNames: 'mirador.[ext]',
...(
process.env.NETLIFY ? {
build: {
rollupOptions: {
external: ['__tests__/*', '__mocks__/*'],
input: 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)),
]),
),
},
sourcemap: true,
},
},
sourcemap: true,
},
} : {
build: {
lib: {
entry: './src/index.js',
fileName: (format) => (format === 'umd' ? 'mirador.js' : 'mirador.es.js'),
formats: ['es', 'umd'],
name: 'Mirador',
},
rollupOptions: {
external: ['__tests__/*', '__mocks__/*'],
output: {
assetFileNames: 'mirador.[ext]',
},
},
sourcemap: true,
},
}
),
esbuild: {
exclude: [],
// Matches .js and .jsx in __tests__ and .jsx in src
Expand Down
Loading