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
|
// @ts-check
import { builtinModules } from 'module';
// `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless.
// @ts-expect-error
import { chrome, node } from '../../.electron-vendors.cache.json';
/** @type string */
const PACKAGE_ROOT = __dirname;
/**
* @type {import('vite').UserConfig}
* @see https://vitejs.dev/config/
*/
const config = {
mode: process.env.MODE,
root: PACKAGE_ROOT,
envDir: process.cwd(),
build: {
sourcemap: 'inline',
target: [
`chrome${chrome}`,
`node${node}`
],
outDir: 'dist',
lib: {
entry: 'src/index.ts',
formats: ['cjs', 'es'],
fileName: (format) => format === 'cjs' ? 'index.cjs' : `index.${format}.js`,
},
rollupOptions: {
external: [
'mobx',
'mobx-state-tree',
...builtinModules,
],
},
emptyOutDir: false, // Do not remove `.d.ts` files.
brotliSize: false,
},
};
export default config;
|