Skip to content

Commit

Permalink
Add netlify build.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 27, 2024
1 parent 30d4ee8 commit 031c1dc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
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/"
56 changes: 41 additions & 15 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]',
},
},
sourcemap: true,
},
...(
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,
}

Check failure on line 32 in vite.config.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing trailing comma

Check failure on line 32 in vite.config.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing trailing comma
} : {
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,
}

Check failure on line 48 in vite.config.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing trailing comma

Check failure on line 48 in vite.config.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Missing trailing comma
}
),
esbuild: {
exclude: [],
// Matches .js and .jsx in __tests__ and .jsx in src
Expand Down

0 comments on commit 031c1dc

Please sign in to comment.