Last active
December 10, 2015 21:26
-
-
Save geowarin/b6613bf1ddbbd16ec0ab to your computer and use it in GitHub Desktop.
gulpfile.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var downloadelectron = require('gulp-download-electron'); | |
var shell = require('gulp-shell'); | |
var packageJson = require('./package.json'); | |
var electron = require('gulp-electron'); | |
gulp.task('package', function() { | |
gulp.src("") | |
.pipe(electron({ | |
src: '.', | |
packageJson: packageJson, | |
release: './release', | |
cache: './cache', | |
version: 'v0.28.1', | |
//packaging: true, | |
platforms: ['darwin-x64'] | |
})) | |
.pipe(gulp.dest("")); | |
}); | |
gulp.task('download', function (cb) { | |
downloadelectron({ | |
version: '0.28.1', | |
outputDir: 'cache' | |
}, cb); | |
}); | |
gulp.task('default', ['download'], function () { | |
// gulp.watch('src/**/*.js', ['js']); | |
// gulp.watch('index.html', ['copy']); | |
// gulp.watch('styles/**/*.less', ['styles']); | |
// gulp.watch('images/**', ['images']); | |
// | |
// livereload.listen(); | |
var env = process.env; | |
env.NODE_ENV = 'development'; | |
if(process.platform === 'win32') { | |
gulp.src('').pipe(shell(['cache\\electron.exe .'], { | |
env: env | |
})); | |
} else { | |
gulp.src('').pipe(shell(['./cache/Electron.app/Contents/MacOS/Electron .'], { | |
env: env | |
})); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
We are using io.js <script>document.write(process.version)</script> | |
and Electron <script>document.write(process.versions['electron'])</script>. | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('app'); // Module to control application life. | |
var BrowserWindow = require('browser-window'); // Module to create native browser window. | |
// Report crashes to our server. | |
require('crash-reporter').start(); | |
// Keep a global reference of the window object, if you don't, the window will | |
// be closed automatically when the javascript object is GCed. | |
var mainWindow = null; | |
// Quit when all windows are closed. | |
app.on('window-all-closed', function() { | |
if (process.platform != 'darwin') { | |
app.quit(); | |
} | |
}); | |
// This method will be called when Electron has done everything | |
// initialization and ready for creating browser windows. | |
app.on('ready', function() { | |
// Create the browser window. | |
mainWindow = new BrowserWindow({width: 800, height: 600}); | |
// and load the index.html of the app. | |
mainWindow.loadUrl('file://' + __dirname + '/index.html'); | |
// Open the devtools. | |
mainWindow.openDevTools(); | |
// Emitted when the window is closed. | |
mainWindow.on('closed', function() { | |
// Dereference the window object, usually you would store windows | |
// in an array if your app supports multi windows, this is the time | |
// when you should delete the corresponding element. | |
mainWindow = null; | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "your-app", | |
"version": "0.1.0", | |
"main": "main.js", | |
"devDependencies": { | |
"electron": "^0.4.1", | |
"gulp": "^3.9.0", | |
"gulp-download-electron": "0.0.5", | |
"gulp-electron": "0.0.5", | |
"gulp-shell": "^0.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment