From a8199323091e2e091131220307463b420fe1ae0e Mon Sep 17 00:00:00 2001 From: Jon Braz Date: Tue, 4 Jun 2019 21:23:25 +0000 Subject: [PATCH] Add babel to gulp buildDev workflow for js compilation --- gulp/tasks/javascript.js | 16 +++++++++ gulpfile.babel.js | 3 +- package-lock.json | 77 ++++++++++++++++++++++++---------------- package.json | 2 ++ 4 files changed, 67 insertions(+), 31 deletions(-) diff --git a/gulp/tasks/javascript.js b/gulp/tasks/javascript.js index 0b9fe0b19..1891fec57 100644 --- a/gulp/tasks/javascript.js +++ b/gulp/tasks/javascript.js @@ -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: { @@ -53,3 +54,18 @@ export const lint = () => gulp .src(context.lint) .pipe(eslint()) .pipe(eslint.format()); + +/** + * Compile with Babel + */ +export const compileJs = () => gulp + .src([ + join(tmp, 'apps', '**', '*.js'), + ]) + .pipe(babel({ + babelrc: false, + ignore: ['**/node_modules'], + plugins: ['babel-plugin-transform-object-rest-spread'], + presets: ['env'] + })) + .pipe(gulp.dest(join(tmp, 'apps'))); diff --git a/gulpfile.babel.js b/gulpfile.babel.js index e552a61fd..6d8952623 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -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 { @@ -20,6 +20,7 @@ const buildProd = gulp.series( moveFilesToTmp, compileSass, templates, + compileJs, require, minifyJs, css, diff --git a/package-lock.json b/package-lock.json index 5b1d4ea8d..1c801105b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -742,6 +742,12 @@ "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", "dev": true }, + "babel-plugin-syntax-object-rest-spread": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", + "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", + "dev": true + }, "babel-plugin-syntax-trailing-function-commas": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", @@ -1004,6 +1010,16 @@ "babel-runtime": "^6.22.0" } }, + "babel-plugin-transform-object-rest-spread": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", + "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", + "dev": true, + "requires": { + "babel-plugin-syntax-object-rest-spread": "^6.8.0", + "babel-runtime": "^6.26.0" + } + }, "babel-plugin-transform-regenerator": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", @@ -3171,8 +3187,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3193,14 +3208,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3215,20 +3228,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3345,8 +3355,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3358,7 +3367,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3373,7 +3381,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3381,14 +3388,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3407,7 +3412,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3488,8 +3492,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3501,7 +3504,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3587,8 +3589,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3624,7 +3625,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3644,7 +3644,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3688,14 +3687,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -3991,6 +3988,26 @@ } } }, + "gulp-babel": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/gulp-babel/-/gulp-babel-7.0.1.tgz", + "integrity": "sha512-UqHS3AdxZyJCRxqnAX603Dj3k/Wx6hzcgmav3QcxvsIFq3Y8ZkU7iXd0O+JwD5ivqCc6o0r1S7tCB/xxLnuSNw==", + "dev": true, + "requires": { + "plugin-error": "^1.0.1", + "replace-ext": "0.0.1", + "through2": "^2.0.0", + "vinyl-sourcemaps-apply": "^0.2.0" + }, + "dependencies": { + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + } + } + }, "gulp-cached": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/gulp-cached/-/gulp-cached-1.1.1.tgz", diff --git a/package.json b/package.json index ba4d6a106..6a174c32c 100644 --- a/package.json +++ b/package.json @@ -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.7", @@ -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",