Created gulp task `compile-es5-lib` (WIP, not yet compiling less into css)

This commit is contained in:
jos 2017-01-01 20:08:10 +01:00
parent 349e6015a3
commit d2e1bed9d6
4 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,4 @@
{ {
"presets": ["es2015", "stage-3", "stage-2"], "presets": ["es2015", "stage-2"],
"plugins": ["transform-flow-strip-types"] "plugins": ["transform-flow-strip-types"]
} }

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.idea .idea
dist dist
lib
downloads downloads
node_modules node_modules
flow-typed flow-typed

View File

@ -4,6 +4,7 @@ const gulpMultiProcess = require('gulp-multi-process')
const gutil = require('gulp-util') const gutil = require('gulp-util')
const shell = require('gulp-shell') const shell = require('gulp-shell')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const babel = require('gulp-babel')
const webpack = require('webpack') const webpack = require('webpack')
const browserSync = require('browser-sync').create() const browserSync = require('browser-sync').create()
@ -25,6 +26,7 @@ const ENTRY = './src/index.js'
const ENTRY_REACT = './src/components/JSONEditor.js' const ENTRY_REACT = './src/components/JSONEditor.js'
const HEADER = './src/header.js' const HEADER = './src/header.js'
const DIST = './dist' const DIST = './dist'
const LIB = './lib'
const EMPTY = __dirname + '/src/utils/empty.js' const EMPTY = __dirname + '/src/utils/empty.js'
// generate banner with today's date and correct version // generate banner with today's date and correct version
@ -187,6 +189,7 @@ function createBundleTask (compiler) {
// make dist folder // make dist folder
gulp.task('mkdir', function () { gulp.task('mkdir', function () {
mkdirp.sync(DIST) mkdirp.sync(DIST)
mkdirp.sync(LIB)
}) })
// bundle javascript // bundle javascript
@ -195,10 +198,25 @@ gulp.task('bundle', ['mkdir'], createBundleTask(compiler))
// bundle minimalist version of javascript // bundle minimalist version of javascript
gulp.task('bundle-minimalist', ['mkdir'], createBundleTask(compilerMinimalist)) 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 // bundle react version
// TODO: remove bundle-react again? (use ./lib instead)
gulp.task('bundle-react', ['mkdir'], createBundleTask(compilerReact)) gulp.task('bundle-react', ['mkdir'], createBundleTask(compilerReact))
// bundle react minimalist version // bundle react minimalist version
// TODO: remove bundle-react-minimalist again? (use ./lib instead)
gulp.task('bundle-react-minimalist', ['mkdir'], createBundleTask(compilerReactMinimalist)) gulp.task('bundle-react-minimalist', ['mkdir'], createBundleTask(compilerReactMinimalist))
// TODO: zip file using archiver // TODO: zip file using archiver
@ -233,7 +251,6 @@ gulp.task('default', function(done) {
return gulpMultiProcess([ return gulpMultiProcess([
'bundle', 'bundle',
'bundle-minimalist', 'bundle-minimalist',
'bundle-react', 'compile-es5-lib'
'bundle-react-minimalist'
], done); ], done);
}) })

View File

@ -44,6 +44,7 @@
"flow-bin": "0.36.0", "flow-bin": "0.36.0",
"graceful-fs": "4.1.11", "graceful-fs": "4.1.11",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-multi-process": "0.1.0", "gulp-multi-process": "0.1.0",
"gulp-shell": "0.5.2", "gulp-shell": "0.5.2",
"gulp-util": "3.0.7", "gulp-util": "3.0.7",