This repository serves as a boilerplate for developing desktop applications using Electron, React, Tailwind CSS, and TypeScript. It includes all necessary configurations and dependencies to get you started quickly.
This boilerplate provides a solid foundation for building desktop applications with Electron, React, Tailwind CSS, and TypeScript. It includes configurations for Webpack, Babel, and PostCSS, ensuring a smooth development experience.
Before you begin, ensure you have met the following requirements:
Clone the repository and install the dependencies:
git clone https://github.com/carmineoncode/electron-app-boilerplate.git
cd electron-app-boilerplate
npm install
# or
yarn install
Ensure you have the necessary environment variables set up. Create a .env
file in the root directory if needed.
To start the development server and the Electron app, run:
npm start
# or
yarn start
In another terminal, run:
npm run electron
# or
yarn electron
electron-app-boilerplate/
├── build/ # Production build
├── dist/ # Electron executables
├── node_modules/ # Node.js modules
├── src/ # Source files
│ ├── App.tsx # Main React component
│ ├── index.tsx # Entry point for React
│ ├── index.css # Tailwind CSS imports
│ └── index.html # HTML template
├── .babelrc # Babel configuration
├── .gitignore # Git ignore file
├── package.json # NPM scripts and dependencies
├── postcss.config.js # PostCSS configuration
├── tailwind.config.js # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
├── webpack.config.js # Webpack configuration
├── main.js # Electron main process
├── preload.js # Electron preload script
├── assets/ # Icons and other assets
│ ├── icon.png # Icon for Linux
│ ├── icon.ico # Icon for Windows
│ └── icon.icns # Icon for macOS
└── README.md # Project documentation
npm start
/ yarn start
: Start the development server.npm run electron
/ yarn electron
: Start the Electron app in development mode.npm run build
/ yarn build
: Build the project for production.npm run electron:prod
/ yarn electron:prod
: Start the Electron app in production mode.npm run dist
/ yarn dist
: Build the project and create executables.To create a production build and generate executables, run:
npm run dist
# or
yarn dist
This will create a production build in the build
directory and generate executables in the dist
directory.
This project follows Electron's security guidelines. Key security features include:
For more information, refer to the Electron Security Documentation.
In development mode, you can open the DevTools by using the custom menu:
CmdOrCtrl+R
to reload the window.CmdOrCtrl+Shift+I
to open or close the DevTools.Note: The DevTools are not accessible in production mode.
To configure the icons for your Electron app, place your icon files in the assets
directory. The following icon formats and resolutions are supported:
icon.ico
(16x16, 32x32, 48x48, 64x64, 128x128, 256x256)icon.icns
(16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024)icon.png
(16x16, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512)Update the package.json
file to point to your icon files:
"build": {
"appId": "com.example.electronapp",
"files": [
"build/**/*",
"main.js",
"preload.js",
"package.json"
],
"directories": {
"output": "dist",
"buildResources": "assets"
},
"win": {
"icon": "assets/icon.ico"
},
"mac": {
"icon": "assets/icon.icns"
},
"linux": {
"icon": "assets/icon.png"
}
}
Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
This project is licensed under the MIT License. See the LICENSE file for details.