status-web/packages/status-js/vite.config.ts

49 lines
1.0 KiB
TypeScript
Raw Normal View History

/// <reference types="vitest" />
import { defineConfig } from 'vite'
import { dependencies } from './package.json'
import type { Alias } from 'vite'
const external = [
...Object.keys(dependencies || {}),
// ...Object.keys(peerDependencies || {}),
].map(name => new RegExp(`^${name}(/.*)?`))
2022-06-28 14:54:21 +00:00
export default defineConfig(({ mode }) => {
const alias: Alias[] = []
if (mode === 'test') {
alias.push({
/**
* Note: `happy-dom` nor `jsdom` have Crypto implemented (@see https://github.com/jsdom/jsdom/issues/1612)
*/
find: /^.*\/crypto\/pbkdf2.browser$/,
replacement: 'ethereum-cryptography/pbkdf2',
})
}
return {
build: {
2022-06-28 14:54:21 +00:00
target: 'es2020',
lib: {
entry: './src/index.ts',
fileName: 'index',
formats: ['es'],
},
2022-06-28 14:54:21 +00:00
sourcemap: true,
emptyOutDir: mode === 'production',
rollupOptions: {
external,
},
},
resolve: {
alias,
},
test: {
environment: 'happy-dom',
},
}
})