Skip to content

[Bug] Having alias for electron folder disables hot reload #249

@mchammer104

Description

@mchammer104

Describe the bug

Hi everybody. I made '@@' for electron folder. But, for some reason it disables hot reload and any time I change anything in the main process it only shows this in the terminal and then nothing happens.

build started...
transforming (1) electron\main.ts

Here is my Vite config.

import {defineConfig} from 'vite'
import path from 'node:path'
import electron from 'vite-plugin-electron/simple'
import react from '@vitejs/plugin-react'
import svgr from 'vite-plugin-svgr';
import visualizer from "rollup-plugin-visualizer";

export default defineConfig({
    plugins: [
        visualizer({
            filename: 'dist/stats.html', // Output file path
            open: false,
        }),
        react(),
        svgr(),
        electron({
            main: {
                // Shortcut of `build.lib.entry`.
                entry: 'electron/main.ts',
                vite: {
                    resolve: {
                        alias: {'@@': path.resolve(__dirname, 'electron')}
                    }
                }
            },
            preload: {
                // Shortcut of `build.rollupOptions.input`.
                // Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
                input: path.join(__dirname, 'electron/preload.ts'),
            },
            // Ployfill the Electron and Node.js built-in modules for Renderer process.
            // See 👉 https://github.com/electron-vite/vite-plugin-electron-renderer
            renderer: {},
        }),
    ],
    resolve: {
        alias: [
            {find: '@', replacement: path.resolve(__dirname, 'src')},
        ],
    },

    build: {
        sourcemap: true,
    }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions