-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvite-builder.config.ts
44 lines (43 loc) · 1.02 KB
/
vite-builder.config.ts
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
import { defineConfig, type UserConfig } from 'vite';
export function viteConfig(
sitePart: 'admin' | 'frontend',
entry: string
): UserConfig {
return defineConfig({
build: {
emptyOutDir: false,
lib: {
entry: `src/ts/${sitePart}/${entry}.ts`,
name: entry,
formats: ['iife'],
},
rollupOptions: {
external: [
'@wordpress/block-editor',
'@wordpress/blocks',
'@wordpress/components',
'@wordpress/editor',
'@wordpress/element',
'imagelightbox',
'jquery',
'justified-layout',
'tinymce',
],
output: {
entryFileNames: `${sitePart}/js/[name].min.js`,
globals: {
'@wordpress/block-editor': 'wp.blockEditor',
'@wordpress/blocks': 'wp.blocks',
'@wordpress/components': 'wp.components',
'@wordpress/editor': 'wp.editor',
'@wordpress/element': 'wp.element',
imagelightbox: 'imagelightbox',
jquery: 'jQuery',
'justified-layout': "require('justified-layout')",
tinymce: 'tinymce',
},
},
},
},
});
}