-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import '@testing-library/jest-dom'; | ||
import { vi } from 'vitest'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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'; | ||
import pkg from './package.json'; | ||
|
||
/** | ||
* Vite configuration | ||
*/ | ||
export default defineConfig({ | ||
...( | ||
process.env.NETLIFY ? { | ||
build: { | ||
rollupOptions: { | ||
external: ['__tests__/*', '__mocks__/*'], | ||
input: Object.fromEntries( | ||
globSync('./demo/src/*.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( | ||
'demo/src/', | ||
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, | ||
}, | ||
} : { | ||
build: { | ||
lib: { | ||
entry: './src/index.js', | ||
fileName: (format) => (format === 'umd' ? 'mirador-dl-plugin.js' : 'mirador-dl-plugin.es.js'), | ||
formats: ['es', 'umd'], | ||
name: 'MiradorDlPlugin', | ||
}, | ||
rollupOptions: { | ||
external: Object.keys(pkg.peerDependencies || {}), | ||
output: { | ||
assetFileNames: 'mirador-dl-plugin.[ext]', | ||
}, | ||
}, | ||
sourcemap: true, | ||
}, | ||
} | ||
), | ||
esbuild: { | ||
exclude: [], | ||
// Matches .js and .jsx in __tests__ and .jsx in src | ||
include: [/__tests__\/.*\.(js|jsx)$/, /src\/.*\.jsx?$/], | ||
loader: 'jsx', | ||
}, | ||
optimizeDeps: { | ||
esbuildOptions: { | ||
plugins: [ | ||
{ | ||
name: 'load-js-files-as-jsx', | ||
// TODO: rename all our files to .jsx ... | ||
/** */ | ||
setup(build) { | ||
build.onLoad({ filter: /(src|__tests__)\/.*\.js$/ }, async (args) => ({ | ||
contents: await fs.readFile(args.path, 'utf8'), | ||
loader: 'jsx', | ||
})); | ||
}, | ||
}, | ||
], | ||
}, | ||
include: ['@emotion/styled'], | ||
}, | ||
plugins: [react()], | ||
resolve: { | ||
alias: { | ||
'@tests/': fileURLToPath(new URL('./__tests__', import.meta.url)), | ||
}, | ||
}, | ||
server: { | ||
open: '/demo/src/index.html', | ||
port: '4444', | ||
}, | ||
}); |
Oops, something went wrong.