Simple build tasks in order to use React
This commit is contained in:
parent
dc9794b1f5
commit
aac547a54c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
|
build/
|
||||||
release/
|
release/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
|
|
43
gulpfile.js
43
gulpfile.js
|
@ -2,12 +2,16 @@
|
||||||
|
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var prettify = require('gulp-jsbeautifier');
|
var prettify = require('gulp-jsbeautifier');
|
||||||
|
var babel = require('gulp-babel');
|
||||||
|
var changed = require('gulp-changed');
|
||||||
|
var del = require('del');
|
||||||
var electron = require('electron-connect').server.create({
|
var electron = require('electron-connect').server.create({
|
||||||
path: './src'
|
path: './build'
|
||||||
});
|
});
|
||||||
var packager = require('electron-packager');
|
var packager = require('electron-packager');
|
||||||
|
|
||||||
var sources = ['**/*.js', '**/*.css', '**/*.html', '!**/node_modules/**', '!release/**'];
|
var sources = ['**/*.js', '**/*.css', '**/*.html', '!**/node_modules/**', '!build/**', '!release/**'];
|
||||||
|
var build_dest = 'build';
|
||||||
|
|
||||||
gulp.task('prettify', ['sync-meta'], function() {
|
gulp.task('prettify', ['sync-meta'], function() {
|
||||||
gulp.src(sources)
|
gulp.src(sources)
|
||||||
|
@ -26,6 +30,29 @@ gulp.task('prettify', ['sync-meta'], function() {
|
||||||
.pipe(gulp.dest('.'));
|
.pipe(gulp.dest('.'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('build', ['build:copy', 'build:jsx']);
|
||||||
|
|
||||||
|
gulp.task('build:clean', function() {
|
||||||
|
return del(build_dest + '/**/*');
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build:copy', ['sync-meta'], function() {
|
||||||
|
return gulp.src(['src/**', '!**/*.jsx'])
|
||||||
|
.pipe(changed(build_dest))
|
||||||
|
.pipe(gulp.dest(build_dest));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build:jsx', function() {
|
||||||
|
return gulp.src(['src/**/*.jsx', '!src/node_modules/**'])
|
||||||
|
.pipe(changed(build_dest, {
|
||||||
|
extension: '.js'
|
||||||
|
}))
|
||||||
|
.pipe(babel({
|
||||||
|
presets: ['react']
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(build_dest));
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('serve', function() {
|
gulp.task('serve', function() {
|
||||||
var options = ['--livereload'];
|
var options = ['--livereload'];
|
||||||
electron.start(options);
|
electron.start(options);
|
||||||
|
@ -38,7 +65,7 @@ gulp.task('serve', function() {
|
||||||
function makePackage(platform, arch) {
|
function makePackage(platform, arch) {
|
||||||
var packageJson = require('./src/package.json');
|
var packageJson = require('./src/package.json');
|
||||||
packager({
|
packager({
|
||||||
dir: './src',
|
dir: './' + build_dest,
|
||||||
name: packageJson.name,
|
name: packageJson.name,
|
||||||
platform: platform,
|
platform: platform,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
|
@ -67,23 +94,23 @@ function makePackage(platform, arch) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('package', ['sync-meta'], function() {
|
gulp.task('package', ['build'], function() {
|
||||||
makePackage(process.platform, 'all');
|
makePackage(process.platform, 'all');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('package:all', ['sync-meta'], function() {
|
gulp.task('package:all', ['build'], function() {
|
||||||
makePackage('all', 'all');
|
makePackage('all', 'all');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('package:windows', ['sync-meta'], function() {
|
gulp.task('package:windows', ['build'], function() {
|
||||||
makePackage('win32', 'all');
|
makePackage('win32', 'all');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('package:osx', ['sync-meta'], function() {
|
gulp.task('package:osx', ['build'], function() {
|
||||||
makePackage('darwin', 'all');
|
makePackage('darwin', 'all');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('package:linux', ['sync-meta'], function() {
|
gulp.task('package:linux', ['build'], function() {
|
||||||
makePackage('linux', 'all');
|
makePackage('linux', 'all');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,19 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "cd src && npm install",
|
"postinstall": "cd src && npm install",
|
||||||
"start": "electron src",
|
"start": "gulp build && electron build",
|
||||||
"test": "mocha"
|
"test": "mocha"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"babel-preset-react": "^6.3.13",
|
||||||
"chromedriver": "^2.20.0",
|
"chromedriver": "^2.20.0",
|
||||||
|
"del": "^2.2.0",
|
||||||
"electron-connect": "^0.3.3",
|
"electron-connect": "^0.3.3",
|
||||||
"electron-packager": "^5.1.0",
|
"electron-packager": "^5.1.0",
|
||||||
"electron-prebuilt": "^0.35.1",
|
"electron-prebuilt": "^0.35.1",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
|
"gulp-babel": "^6.1.1",
|
||||||
|
"gulp-changed": "^1.3.0",
|
||||||
"gulp-jsbeautifier": "^1.0.1",
|
"gulp-jsbeautifier": "^1.0.1",
|
||||||
"mocha": "^2.3.4",
|
"mocha": "^2.3.4",
|
||||||
"should": "^8.0.1",
|
"should": "^8.0.1",
|
||||||
|
|
Loading…
Reference in a new issue