-
Notifications
You must be signed in to change notification settings - Fork 22
/
vite.config.js
49 lines (37 loc) · 1.21 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
import { readFileSync } from 'fs'
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
// Note that Vite tries to inject `__dirname` but if we leave it undefined then
// Node will complain ("ERROR: __dirname is not defined in ES module scope") so
// we use our own special name here
const libDir = dirname(fileURLToPath(import.meta.url))
const pkg = JSON.parse(readFileSync('package.json'))
export default defineConfig({
// Only build the library in production mode (dev mode is not applicable)
mode: 'production',
// Use this directory as the root directory for the library
root: libDir,
// Don't clear the screen
clearScreen: false,
plugins: [
// Process Svelte files
svelte({ emitCss: false })
],
build: {
// Write output file to `dist/index.js`
outDir: 'dist',
// TODO: Uncomment for debugging purposes
// minify: false,
lib: {
entry: './src/index.ts',
formats: ['es'],
fileName: () => 'index.js'
},
rollupOptions: {
// Prevent dependencies from being included in packaged library
external: Object.keys(pkg.dependencies)
}
}
})