Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add babel to gulp buildDev workflow for js compilation #412

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions gulp/tasks/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import gulp from 'gulp';
import uglify from 'gulp-uglify';
import eslint from 'gulp-eslint';
import { app, src, tmp } from '../paths.js';
import babel from 'gulp-babel';

const config = {
app: {
Expand Down Expand Up @@ -53,3 +54,20 @@ export const lint = () => gulp
.src(context.lint)
.pipe(eslint())
.pipe(eslint.format());

/**
* Compile *.js files in /apps/** and /js/lib to ES5 with Babel
*/
export const compileJs = () => gulp
.src([
join(tmp, 'apps', '**', '*.js'),
join(tmp, 'js', 'lib', '**', '*.js')
], { base: tmp })
.pipe(babel({
babelrc: false,
compact: true,
ignore: ['**/node_modules'],
plugins: ['babel-plugin-transform-object-rest-spread'],
presets: ['env']
}))
.pipe(gulp.dest(tmp));
4 changes: 3 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { serve, watch } from './gulp/tasks/server.js';
import gulp from 'gulp';
import require from './gulp/tasks/require.js';
import writeVersion from './gulp/tasks/write-version.js';
import { lint, minifyJs, minifyJsApp } from './gulp/tasks/javascript.js';
import { lint, minifyJs, minifyJsApp, compileJs } from './gulp/tasks/javascript.js';
import { templates, templatesApp } from './gulp/tasks/templates.js';
import { compileSass, css, minifyCssApp } from './gulp/tasks/style.js';
import {
Expand All @@ -20,6 +20,7 @@ const buildProd = gulp.series(
moveFilesToTmp,
compileSass,
templates,
compileJs,
require,
minifyJs,
css,
Expand All @@ -40,6 +41,7 @@ const buildApp = gulp.series(
moveFilesToTmp,
compileSass,
templatesApp,
compileJs,
require,
minifyJsApp,
minifyCssApp,
Expand Down
77 changes: 47 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"browser-sync": "^2.26.10",
Expand All @@ -30,6 +31,7 @@
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"gulp": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-cached": "^1.1.1",
"gulp-clean-css": "^3.9.0",
"gulp-concat": "^2.6.1",
Expand Down