Commit 78a414ab authored by carlosperate's avatar carlosperate

Electron: Cherry-pick boilerplate updates.

Synchronised up to version 782150ea4263aee62214ef5996ed89b4b32c0ec3
"Specs bundled with Rollup"
released on the 20th September 2015 https://github.com/szwacz/electron-boilerplate/commit/782150ea4263aee62214ef5996ed89b4b32c0ec3
parent 0ec9cd65
......@@ -65,6 +65,13 @@ coverage.xml
# Sphinx documentation
docs/_build/
###################
# Node / electron #
###################
# Comprehensive gitignore file in /package/electron directory
# due to build cwd, log might placed in root directory
npm-debug.log*
####################
# Project specific #
####################
......
......@@ -47,8 +47,6 @@ coverage
# Dependency directory (https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git)
node_modules
bower_components
####################
# Project specific #
####################
......
......@@ -69,8 +69,8 @@ app.on('ready', function() {
transparent: false,
frame: true,
show: false,
'node-integration': true,
'web-preferences': {
'node-integration': true,
'web-security': true,
'allow-displaying-insecure-content': false,
'allow-running-insecure-content': false,
......
......@@ -11,7 +11,7 @@
"target": "development"
},
"dependencies": {
"fs-jetpack": "^0.6.5",
"fs-jetpack": "^0.7.0",
"winston": "^1.0.1"
},
"repository" : {
......
{
"devDependencies": {
"asar": "^0.7.2",
"electron-prebuilt": "^0.31.2",
"electron-prebuilt": "^0.32.2",
"fs-jetpack": "^0.7.0",
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-less": "^3.0.3",
"gulp-util": "^3.0.6",
"q": "^1.4.1",
"rollup": "^0.15.0",
"tree-kill": "^0.1.1",
"yargs": "^3.15.0"
},
......
'use strict';
var pathUtil = require('path');
var Q = require('q');
var gulp = require('gulp');
var babel = require('gulp-babel');
var rollup = require('rollup');
var less = require('gulp-less');
var jetpack = require('fs-jetpack');
......@@ -12,19 +14,10 @@ var srcDir = projectDir.cwd('./app');
var destDir = projectDir.cwd('./build');
var paths = {
jsCodeToTranspile: [
'app/**/*.js',
'!app/main.js',
'!app/*.js',
'!app/node_modules/**',
'!app/bower_components/**',
'!app/vendor/**'
],
copyFromAppDir: [
'./main.js',
'./main.js', // maybe need to remove this one too
'./*.js',
'./node_modules/**',
'./bower_components/**',
'./vendor/**',
'./**/*.html'
],
......@@ -49,13 +42,42 @@ gulp.task('copy', ['clean'], copyTask);
gulp.task('copy-watch', copyTask);
var transpileTask = function () {
return gulp.src(paths.jsCodeToTranspile)
.pipe(babel({ modules: 'amd' }))
.pipe(gulp.dest(destDir.path()));
var bundle = function (src, dest) {
var deferred = Q.defer();
rollup.rollup({
entry: src
}).then(function (bundle) {
var jsFile = pathUtil.basename(dest);
var result = bundle.generate({
format: 'iife',
sourceMap: true,
sourceMapFile: jsFile,
});
return Q.all([
destDir.writeAsync(dest, result.code + '\n//# sourceMappingURL=' + jsFile + '.map'),
destDir.writeAsync(dest + '.map', result.map.toString()),
]);
}).then(function () {
deferred.resolve();
}).catch(function (err) {
console.error(err);
});
return deferred.promise;
};
var bundleApplication = function () {
return Q.all([
bundle(srcDir.path('main.js'), destDir.path('main.js')),
]);
};
var bundleTask = function () {
return bundleApplication();
};
gulp.task('transpile', ['clean'], transpileTask);
gulp.task('transpile-watch', transpileTask);
gulp.task('bundle', ['clean'], bundleTask);
gulp.task('bundle-watch', bundleTask);
var lessTask = function () {
......@@ -69,13 +91,16 @@ gulp.task('less-watch', lessTask);
gulp.task('finalize', ['clean'], function () {
var manifest = srcDir.read('package.json', 'json');
// Add "dev" or "test" suffix to name, so Electron will write all data
// like cookies and localStorage in separate places for each environment.
switch (utils.getEnvName()) {
case 'development':
// Add "dev" suffix to name, so Electron will write all
// data like cookies and localStorage into separate place.
manifest.name += '-dev';
manifest.productName += ' Dev';
break;
case 'test':
throw "test build has been removed";
break;
}
destDir.write('package.json', manifest);
......@@ -85,10 +110,10 @@ gulp.task('finalize', ['clean'], function () {
gulp.task('watch', function () {
gulp.watch(paths.jsCodeToTranspile, ['transpile-watch']);
gulp.watch('app/**/*.js', ['bundle-watch']);
gulp.watch(paths.copyFromAppDir, { cwd: 'app' }, ['copy-watch']);
gulp.watch('app/**/*.less', ['less-watch']);
});
gulp.task('build', ['transpile', 'less', 'copy', 'finalize']);
gulp.task('build', ['bundle', 'less', 'copy', 'finalize']);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment