Skip to content

Commit

Permalink
Added basing electron app
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenekrejda committed May 18, 2017
1 parent c32dafc commit 62438a8
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
7 changes: 7 additions & 0 deletions javascripts/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('../less/main.less');

'use strict';

import React from "react";

React.render( < div className = "myDiv" > Hello Electron! < /div>, document.getElementById('content'));
10 changes: 10 additions & 0 deletions less/main.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@body-bg: #000;
@myDiv-fg: #f00;

body {
background-color: @body-bg;
}

div.myDiv {
color: @myDiv-fg;
}
25 changes: 25 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var app = require('app');
var BrowserWindow = require('browser-window');

require('crash-reporter').start();

app.on('window-all-closed', function () {
if (process.platform != 'darwin') {
app.quit();
}
});

app.on('ready', function () {
mainWindow = new BrowserWindow({
width: 1360,
height: 800
});

mainWindow.loadUrl('file://' + __dirname + '/public/index.html');

mainWindow.openDevTools();

mainWindow.on('closed', function () {
mainWindow = null;
});
});
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "my-electron-app",
"version": "0.1.0",
"description": "desktop app",
"main": "main.js",
"devDependencies": {
"babel": "^5.6.10",
"babel-core": "^5.6.11",
"babel-loader": "^5.2.2",
"css-loader": "^0.15.1",
"electron-packager": "^4.1.3",
"electron-prebuilt": "^0.28.3",
"electron-rebuild": "^0.2.2",
"less": "^2.5.1",
"less-loader": "^2.2.0",
"node-libs-browser": "^0.5.2",
"style-loader": "^0.12.3",
"webpack": "^1.9.12",
"webpack-dev-server": "^1.9.0"
},
"dependencies": {
"electron-prebuilt": "^0.28.3",
"react": "^0.13.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "./node_modules/electron-prebuilt/dist/electron .",
"watch": "./node_modules/.bin/webpack-dev-server",
"electron-rebuild": "./node_modules/.bin/electron-rebuild"
},
"author": "",
"license": "ISC"
}
14 changes: 14 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<title>My Electron-React app</title>
</head>

<body>
<div id="content"></div>
</body>
<script src="http://localhost:8080/webpack-dev-server.js"></script>
<script src="http://localhost:8080/built/bundle.js"></script>

</html>
39 changes: 39 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var webpack = require('webpack');

module.exports = {
entry: {
app: ['webpack/hot/dev-server', './javascripts/entry.js'],
},

output: {
path: './public/built',
filename: 'bundle.js',
publicPath: 'http://localhost:8080/built/'
},

devServer: {
contentBase: './public',
publicPath: 'http://localhost:8080/built/'
},

module: {
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader'
}
]
},

plugins: [
new webpack.HotModuleReplacementPlugin()
]
}

0 comments on commit 62438a8

Please sign in to comment.