-
-
Notifications
You must be signed in to change notification settings - Fork 595
/
Copy pathvite.config.umd.ts
72 lines (69 loc) · 1.75 KB
/
vite.config.umd.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import commonjs from 'vite-plugin-commonjs'
import terser from '@rollup/plugin-terser';
import { resolve } from 'path';
import pkg from './package.json';
const banner = `/**
* Parse JavaScript SDK v${pkg.version}
*
* Copyright 2015-present Parse Platform
* All rights reserved.
*
* The source tree of this library can be found at:
* https://github.com/parse-community/Parse-SDK-JS
*
* This source code is licensed under the license found in the LICENSE
* file in the root directory of this source tree. Additional legal
* information can be found in the NOTICE file in the same directory.
*/
`;
const FILE_NAME = process.env.PARSE_BUILD === 'browser' ? 'parse' : 'parse.weapp';
const build = {
name: 'Parse',
globals: {
xmlhttprequest: 'XMLHttpRequest',
_process: 'process',
},
banner,
};
const umdBuilds: any = [{
entryFileNames: `${FILE_NAME}.js`,
format: 'umd',
...build,
}, {
entryFileNames: `${FILE_NAME}.min.js`,
format: 'umd',
...build,
plugins: [
terser({
format: {
comments: false,
},
}) as any,
],
}];
export default defineConfig({
plugins: [nodePolyfills(), commonjs()],
define: {
'process.env.PARSE_BUILD': `"${process.env.PARSE_BUILD}"`,
'process.env.npm_package_version': `"${pkg.version}"`,
},
build: {
outDir: 'dist',
emptyOutDir: false,
rollupOptions: {
input: resolve(__dirname, 'src/Parse.ts'),
external: ['xmlhttprequest', '_process'],
output: [...umdBuilds],
},
minify: false,
sourcemap: false,
},
resolve: {
alias: {
'react-native/Libraries/vendor/emitter/EventEmitter': 'events',
'EventEmitter': 'events',
},
},
});