mirror of
https://github.com/status-im/dappconnect-chat-sdk.git
synced 2025-01-12 23:14:53 +00:00
e1c4f0591d
* add pbkdf2 browser implementation * use webcrypto in pbkdf2 * rename pbkdf2 file * use pbkdf2 * add changeset * revert rename * remove browser field from package.json * use `resolve.alias` for pbkdf2 if test * use `mode` in vite.config.ts Co-authored-by: Felicio Mununga <felicio@users.noreply.github.com>
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
/// <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}(/.*)?`))
|
|
|
|
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: {
|
|
target: 'es2020',
|
|
lib: {
|
|
entry: './src/index.ts',
|
|
fileName: 'index',
|
|
formats: ['es'],
|
|
},
|
|
sourcemap: true,
|
|
emptyOutDir: mode === 'production',
|
|
rollupOptions: {
|
|
external,
|
|
},
|
|
},
|
|
resolve: {
|
|
alias,
|
|
},
|
|
test: {
|
|
environment: 'happy-dom',
|
|
},
|
|
}
|
|
})
|