generated from johnedvard/phaser-typescript-spine-vite-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.lib.ts
56 lines (54 loc) · 1.43 KB
/
vite.config.lib.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
45
46
47
48
49
50
51
52
53
54
55
56
import fs from 'fs';
import { defineConfig } from 'vite';
import path from 'path';
// added below polyfills to make near-api-js work with vite
// npm install --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
// npm install --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
fs.rmSync('dist', { recursive: true, force: true }); // v14.14.0
export default defineConfig({
base: './',
plugins: [],
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
build: {
lib: {
entry: path.resolve(__dirname, './src/lib.ts'),
name: 'Toki',
// the proper extensions will be added
fileName: 'toki',
},
commonjsOptions: {
include: [],
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['phaser'],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
phaser: 'Phaser',
},
},
},
},
optimizeDeps: {
disabled: false,
esbuildOptions: {
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
NodeModulesPolyfillPlugin(),
],
},
},
});