2023-01-17 13:32:04 +00:00
|
|
|
/// <reference types="vitest" />
|
|
|
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
2023-04-14 21:27:05 +00:00
|
|
|
import pkg from './package.json'
|
2023-01-17 13:32:04 +00:00
|
|
|
|
|
|
|
const external = [
|
2023-04-14 21:27:05 +00:00
|
|
|
// ...Object.keys(pkg.dependencies || {}),
|
|
|
|
...Object.keys(pkg.peerDependencies || {}),
|
2023-01-17 13:32:04 +00:00
|
|
|
].map(name => new RegExp(`^${name}(/.*)?`))
|
|
|
|
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
return {
|
|
|
|
build: {
|
|
|
|
target: 'es2020',
|
|
|
|
lib: {
|
2024-09-24 16:17:41 +00:00
|
|
|
entry: {
|
|
|
|
'12': 'src/12/index.ts',
|
|
|
|
'16': 'src/16/index.ts',
|
|
|
|
'20': 'src/20/index.ts',
|
|
|
|
social: 'src/social/index.ts',
|
|
|
|
reactions: 'src/reactions/index.ts',
|
|
|
|
},
|
2023-04-14 21:27:05 +00:00
|
|
|
formats: ['es', 'cjs'],
|
2024-09-24 16:17:41 +00:00
|
|
|
fileName: (format, entryName) => `${entryName}/index.${format}.js`,
|
2023-01-17 13:32:04 +00:00
|
|
|
},
|
|
|
|
sourcemap: true,
|
|
|
|
emptyOutDir: mode === 'production',
|
|
|
|
rollupOptions: {
|
|
|
|
external,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
|
|
|
test: {
|
|
|
|
environment: 'happy-dom',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|