├── .babelrc
├── .env
├── .gitignore
├── LICENSE.md
├── README.md
├── app
└── index.js
├── index.html
├── main.js
├── package.json
├── webpack.config.base.js
└── webpack.config.dev.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react", "es2015"]
3 | }
4 |
--------------------------------------------------------------------------------
/.env:
--------------------------------------------------------------------------------
1 | NODE_ENV=development
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | npm-debug.log
3 | node_modules/
4 | dist/
5 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Vu Tran
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Electron Webpack Boilerplate
2 |
3 | Fully-loaded Electron boilerplate
4 |
5 | - [Electron](https://github.com/atom/electron)
6 | - [webpack](https://github.com/webpack/webpack)
7 | - [React](https://github.com/facebook/react)
8 | - [Hot Loader Server](https://github.com/vutran/hot-reload-server)
9 | - [Babel/ES2015](https://github.com/babel/babel)
10 | - [CSS Modules](https://github.com/css-modules/css-modules)
11 | - [Sass](https://github.com/sass/sass)
12 | - [PostCSS](https://github.com/postcss/postcss), [Autoprefixer](https://github.com/postcss/autoprefixer)
13 | - [dotenv](https://github.com/motdotla/dotenv)
14 |
15 | ## Quickstart Guide
16 |
17 | ````
18 | npm install && npm start
19 | ````
20 |
--------------------------------------------------------------------------------
/app/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 |
4 | // Import the app boilerplate
5 | import { Root, configureStore } from 'react-todo'
6 |
7 | // Create the store
8 | const store = configureStore({
9 | info: {
10 | contact_url: 'https://github.com/vutran/electron-webpack-boilerplate/issues',
11 | contact_label: 'Post on GitHub'
12 | }
13 | })
14 |
15 | // Render to the #app element
16 | ReactDOM.render(
17 | ,
18 | document.getElementById('app')
19 | )
20 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Electron React Boilerplate
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/main.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | // Import modules
4 | const electron = require('electron')
5 |
6 | const app = electron.app
7 | const BrowserWindow = electron.BrowserWindow
8 |
9 | // Load environmental variables
10 | require('dotenv').load()
11 |
12 | if (process.env.NODE_ENV === "development") {
13 | let hotReloadServer = require('hot-reload-server')
14 | let webpackConfig = require('./webpack.config.dev')
15 | hotReloadServer(webpackConfig, {
16 | publicPath: '/dist'
17 | }).start()
18 | }
19 |
20 | // Create a variable to hold the window
21 | let mainWindow = null
22 |
23 | app.on('ready', function() {
24 |
25 | // creates a new browser window
26 | mainWindow = new BrowserWindow({
27 | width: 800,
28 | height: 600
29 | })
30 | // load the file
31 | mainWindow.loadURL('file://' + __dirname + '/index.html')
32 | // Register window events
33 | mainWindow.on('closed', function() {
34 | mainWindow = null
35 | })
36 | })
37 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "electon-react-boilerplate",
3 | "version": "0.0.1",
4 | "description": "Electron React Boilerplate",
5 | "main": "main.js",
6 | "scripts": {
7 | "start": "electron ."
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git@github.com:vutran/electron-webpack-boilerplate.git"
12 | },
13 | "keywords": [
14 | "electron",
15 | "webpack",
16 | "react",
17 | "boilerplate",
18 | "node"
19 | ],
20 | "author": "Vu Tran",
21 | "license": "MIT",
22 | "bugs": {
23 | "url": "https://github.com/vutran/electron-react-boilerplate/issues"
24 | },
25 | "homepage": "https://github.com/vutran/electron-react-boilerplate#readme",
26 | "devDependencies": {
27 | "autoprefixer": "^6.1.2",
28 | "babel-core": "^6.3.17",
29 | "babel-eslint": "^4.1.6",
30 | "babel-loader": "^6.2.0",
31 | "babel-preset-es2015": "^6.3.13",
32 | "babel-preset-react": "^6.3.13",
33 | "better-npm-run": "0.0.5",
34 | "css-loader": "^0.23.0",
35 | "dotenv": "^1.2.0",
36 | "electron-prebuilt": "^0.35.4",
37 | "eslint": "^1.10.3",
38 | "eslint-loader": "^1.1.1",
39 | "express": "^4.13.3",
40 | "file-loader": "^0.8.5",
41 | "hot-reload-server": "0.0.4",
42 | "html-loader": "^0.4.0",
43 | "json-loader": "^0.5.4",
44 | "node-sass": "^3.4.2",
45 | "postcss": "^5.0.13",
46 | "postcss-loader": "^0.8.0",
47 | "react": "^0.14.3",
48 | "react-dom": "^0.14.3",
49 | "react-redux": "^4.0.1",
50 | "react-todo": "^0.0.22",
51 | "redux": "^3.0.5",
52 | "sass-loader": "^3.1.2",
53 | "style-loader": "^0.13.0",
54 | "svgo": "^0.6.1",
55 | "svgo-loader": "^1.1.0",
56 | "url-loader": "^0.5.7",
57 | "webpack": "^1.12.9",
58 | "webpack-dev-middleware": "^1.4.0",
59 | "webpack-hot-middleware": "^2.6.0",
60 | "webpack-target-electron-renderer": "^0.3.0"
61 | },
62 | "dependencies": {
63 | "react-redux": "^4.0.1",
64 | "redux-devtools": "^3.0.0",
65 | "redux-devtools-dock-monitor": "^1.0.1",
66 | "redux-devtools-log-monitor": "^1.0.1"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/webpack.config.base.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack')
2 | const path = require('path')
3 |
4 | const config = {
5 | entry: [
6 | path.join(__dirname, '/app/index.js')
7 | ],
8 | output: {
9 | path: path.join(__dirname, '/dist'),
10 | filename: 'bundle.js'
11 | },
12 | module: {
13 | loaders: [
14 | {
15 | test: /\.scss$/,
16 | loaders: ['style', 'css?modules', 'postcss', 'sass']
17 | },
18 | {
19 | test: /\.js$/,
20 | exclude: /node_modules/,
21 | loaders: ['babel']
22 | },
23 | {
24 | test: /\.html$/,
25 | loaders: ['html']
26 | },
27 | {
28 | test: /\.json$/,
29 | loaders: ['json']
30 | }
31 | ]
32 | },
33 | postcss: function() {
34 | return [
35 | require('autoprefixer')
36 | ]
37 | },
38 | plugins: []
39 | }
40 |
41 | module.exports = config
42 |
--------------------------------------------------------------------------------
/webpack.config.dev.js:
--------------------------------------------------------------------------------
1 | // Load modules
2 | const webpack = require('webpack')
3 | const webpackTargetElectronRenderer = require('webpack-target-electron-renderer')
4 | const path = require('path')
5 |
6 | // Load base config
7 | const baseConfig = require('./webpack.config.base')
8 |
9 | // Create the config
10 | const config = Object.create(baseConfig)
11 |
12 | // Set entry points
13 | config.entry = [
14 | 'webpack-hot-middleware/client?path=http://localhost:4000/__webpack_hmr&reload=true',
15 | path.join(__dirname, '/app/index.js')
16 | ]
17 |
18 | // Set output
19 | config.output.publicPath = 'http://localhost:4000/dist/'
20 |
21 | // Enable source maps
22 | config.devtool = 'source-map'
23 |
24 | // ES lint
25 | config.eslint = {
26 | parser: 'babel-eslint'
27 | }
28 |
29 | // Dev plugins
30 | config.plugins.push(
31 | new webpack.optimize.OccurenceOrderPlugin(),
32 | new webpack.HotModuleReplacementPlugin(),
33 | new webpack.NoErrorsPlugin()
34 | )
35 |
36 | // Specify Electron renderer
37 | config.target = webpackTargetElectronRenderer(config)
38 |
39 | // Export module
40 | module.exports = config
41 |
--------------------------------------------------------------------------------