-
Notifications
You must be signed in to change notification settings - Fork 26
/
vite.config.js
42 lines (41 loc) · 1.11 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
import { defineConfig } from 'vite'
import copy from 'rollup-plugin-copy-watch'
import FullReload from 'vite-plugin-full-reload'
export default defineConfig(({command, mode}) => {
console.log('build mode: ', mode)
return {
build: {
lib: {
entry: 'src/main.js',
formats: ['umd'],
name: 'Moegi',
},
rollupOptions: {
output: {
// entryFileNames: `assets/moegi.[format].js`,
entryFileNames: `assets/moegi.js`,
assetFileNames: `assets/moegi.[ext]`,
},
},
},
plugins: [
copy({
watch: mode === 'development' ? ['package.json', 'template/**/*.hbs'] : [],
targets: [{
src: 'package.json',
dest: 'dist',
}, {
src: 'template/**/*.hbs',
dest: 'dist',
transform: (contents, filename) => contents.toString().replace(/__IS_DEV__/g, mode === 'development')
}],
flatten: false,
hook: mode === 'development' ? 'buildStart' : 'writeBundle',
}),
FullReload([
'package.json',
'template/**/*.hbs',
])
],
}
})