aboutsummaryrefslogtreecommitdiffstats
path: root/packages/renderer/vite.config.js
blob: ff34b6d8ff79067283f27092db4ed1be7861a014 (plain) (blame)
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
// @ts-check

/* eslint-env node */

import { builtinModules } from 'module';
import { join } from 'path';
import react from '@vitejs/plugin-react';

// `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless.
// @ts-expect-error
import { chrome } 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,
  plugins: [
    react(),
  ],
  base: '',
  server: {
    fs: {
      strict: true,
    },
  },
  build: {
    sourcemap: true,
    target: `chrome${chrome}`,
    outDir: 'dist',
    assetsDir: '.',
    rollupOptions: {
      external: [
        ...builtinModules,
      ],
    },
    emptyOutDir: true,
    brotliSize: false,
  },
};

export default config;