diff options
Diffstat (limited to 'packages/main/vite.config.js')
-rw-r--r-- | packages/main/vite.config.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/main/vite.config.js b/packages/main/vite.config.js new file mode 100644 index 0000000..45c2c8c --- /dev/null +++ b/packages/main/vite.config.js | |||
@@ -0,0 +1,51 @@ | |||
1 | // @ts-check | ||
2 | |||
3 | import { builtinModules } from 'module'; | ||
4 | import { join } from 'path'; | ||
5 | |||
6 | // `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless. | ||
7 | // @ts-expect-error | ||
8 | import { node } from '../../.electron-vendors.cache.json'; | ||
9 | |||
10 | /** @type string */ | ||
11 | const PACKAGE_ROOT = __dirname; | ||
12 | |||
13 | /** | ||
14 | * @type {import('vite').UserConfig} | ||
15 | * @see https://vitejs.dev/config/ | ||
16 | */ | ||
17 | const config = { | ||
18 | mode: process.env.MODE, | ||
19 | root: PACKAGE_ROOT, | ||
20 | envDir: process.cwd(), | ||
21 | resolve: { | ||
22 | alias: { | ||
23 | '/@/': join(PACKAGE_ROOT, 'src') + '/', | ||
24 | }, | ||
25 | }, | ||
26 | build: { | ||
27 | sourcemap: 'inline', | ||
28 | target: `node${node}`, | ||
29 | outDir: 'dist', | ||
30 | assetsDir: '.', | ||
31 | minify: process.env.MODE !== 'development', | ||
32 | lib: { | ||
33 | entry: 'src/index.ts', | ||
34 | formats: ['cjs'], | ||
35 | }, | ||
36 | rollupOptions: { | ||
37 | external: [ | ||
38 | 'electron', | ||
39 | 'electron-devtools-installer', | ||
40 | ...builtinModules, | ||
41 | ], | ||
42 | output: { | ||
43 | entryFileNames: '[name].cjs', | ||
44 | }, | ||
45 | }, | ||
46 | emptyOutDir: true, | ||
47 | brotliSize: false, | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | export default config; | ||