-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathvite.config.js
59 lines (55 loc) · 1.44 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
50
51
52
53
54
55
56
57
58
59
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
export default defineConfig(({ command, mode }) => {
const base = {
plugins: [
react(),
viteCommonjs(),
],
test: {
environment: 'jsdom',
},
}
if (command === 'build') {
if (mode === 'docs') {
return {
...base,
base: '/react-flickity-component/',
root: resolve(__dirname, 'examples'),
build: {
outDir: '../docs',
emptyOutDir: true,
},
}
} else {
return {
...base,
build: {
sourcemap: true,
lib: {
entry: resolve(__dirname, 'src/index.js'),
name: 'ReactFlickityComponent',
formats: ['es', 'umd'],
fileName: (format) => `react-flickity-component.${format}.js`,
},
rollupOptions: {
external: ['react', 'react-dom', 'imagesloaded', 'prop-types', 'flickity'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
imagesloaded: 'imagesloaded',
'prop-types': 'PropTypes',
},
},
},
},
}
}
}
return base
})