-
Notifications
You must be signed in to change notification settings - Fork 50
/
vite.config.js
38 lines (36 loc) · 995 Bytes
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import analyze from 'rollup-plugin-analyzer'
import { terser } from 'rollup-plugin-terser'
import filesize from 'rollup-plugin-filesize'
import pkg from './package.json'
const production = !process.argv.includes('--watch')
const removeDist = (p) => p.replace('dist/', '')
export default defineConfig({
plugins: [svelte({ hot: !process.env.VITEST })],
test: {
globals: true,
environment: 'jsdom',
},
build: {
rollupOptions: {
input: 'src/index.js',
plugins: [
production && terser(),
production && analyze(),
production && filesize(),
],
},
sourcemap: true,
lib: {
entry: new URL('src/index.js', import.meta.url).pathname,
formats: ['es', 'umd'],
name: pkg.name,
fileName: (format) =>
({
es: removeDist(pkg.module),
umd: removeDist(pkg.main),
}[format]),
},
},
})