Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Bundling Renderer Co | Electron.js Desktop App Development l | BraveProgrammer
  1. Courses
  2. /
  3. Electron.js Desktop App Development

Lesson 9 of 28

·javascript

Bundling Renderer Code – Vite & Webpack

10 mins

Course progress32%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • Vite uses native ES modules for lightning‑fast hot‑reload; Webpack is more configurable for complex pipelines.
  • Output the bundle to a folder the Electron main process can load (`dist/`).
  • Configure the bundler to **exclude Electron built‑ins** (`externals` in Webpack).
  • Keep source maps (`devtool: 'source-map'`) for easier debugging.

Bundling Renderer Code – Vite & Webpack

Vite (fast dev server + Rollup build) example vite.renderer.config.js:

import { defineConfig } from 'vite';
export default defineConfig({
  root: 'src',
  build: {
    outDir: '../dist',
    emptyOutDir: true,
    rollupOptions: {
      input: 'src/index.html'
    }
  }
});

Run vite for dev, vite build for production.

Webpack example (simplified):

// webpack.renderer.config.js
const path = require('path');
module.exports = {
  mode: 'production',
  entry: './src/renderer.js',
  output: { filename: 'renderer.js', path: path.resolve(__dirname, 'dist') },
  module: { rules: [{ test: /\.css$/, use: ['style-loader','css-loader'] }] }
};

Both tools generate a single JS bundle that you load via a <script> tag in index.html.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Electron.js Desktop App DevelopmentBrowse activities
Previous lessonIntegrating Front‑End Frameworks (React/Vue)Continue to lesson 10State Management Across ProcessesBack to Electron.js Desktop App Development curriculum