From d2e1bed9d62da1ae3e84219e0a00af450d6b7e4c Mon Sep 17 00:00:00 2001 From: jos Date: Sun, 1 Jan 2017 20:08:10 +0100 Subject: [PATCH] Created gulp task `compile-es5-lib` (WIP, not yet compiling less into css) --- .babelrc | 2 +- .gitignore | 1 + gulpfile.js | 21 +++++++++++++++++++-- package.json | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.babelrc b/.babelrc index 458cea5..ef5dad5 100755 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { - "presets": ["es2015", "stage-3", "stage-2"], + "presets": ["es2015", "stage-2"], "plugins": ["transform-flow-strip-types"] } diff --git a/.gitignore b/.gitignore index 80f0af7..b6e2196 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea dist +lib downloads node_modules flow-typed diff --git a/gulpfile.js b/gulpfile.js index e50c7de..7b8e9d4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,7 @@ const gulpMultiProcess = require('gulp-multi-process') const gutil = require('gulp-util') const shell = require('gulp-shell') const mkdirp = require('mkdirp') +const babel = require('gulp-babel') const webpack = require('webpack') const browserSync = require('browser-sync').create() @@ -25,6 +26,7 @@ const ENTRY = './src/index.js' const ENTRY_REACT = './src/components/JSONEditor.js' const HEADER = './src/header.js' const DIST = './dist' +const LIB = './lib' const EMPTY = __dirname + '/src/utils/empty.js' // generate banner with today's date and correct version @@ -187,6 +189,7 @@ function createBundleTask (compiler) { // make dist folder gulp.task('mkdir', function () { mkdirp.sync(DIST) + mkdirp.sync(LIB) }) // bundle javascript @@ -195,10 +198,25 @@ gulp.task('bundle', ['mkdir'], createBundleTask(compiler)) // bundle minimalist version of javascript gulp.task('bundle-minimalist', ['mkdir'], createBundleTask(compilerMinimalist)) +// compile the source code into es5 code +gulp.task('compile-es5-lib', ['mkdir'], function () { + // TODO: compile *.less too + return gulp + .src([ + 'src/**/*.js', + '!src/flow/**/*.js', + '!src/resources/**/*.js' + ]) + .pipe(babel()) + .pipe(gulp.dest(LIB)); +}) + // bundle react version +// TODO: remove bundle-react again? (use ./lib instead) gulp.task('bundle-react', ['mkdir'], createBundleTask(compilerReact)) // bundle react minimalist version +// TODO: remove bundle-react-minimalist again? (use ./lib instead) gulp.task('bundle-react-minimalist', ['mkdir'], createBundleTask(compilerReactMinimalist)) // TODO: zip file using archiver @@ -233,7 +251,6 @@ gulp.task('default', function(done) { return gulpMultiProcess([ 'bundle', 'bundle-minimalist', - 'bundle-react', - 'bundle-react-minimalist' + 'compile-es5-lib' ], done); }) diff --git a/package.json b/package.json index 9d61b07..ac36884 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "flow-bin": "0.36.0", "graceful-fs": "4.1.11", "gulp": "3.9.1", + "gulp-babel": "6.1.2", "gulp-multi-process": "0.1.0", "gulp-shell": "0.5.2", "gulp-util": "3.0.7",