Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
Added babel to gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
benbrehaut committed Sep 5, 2017
1 parent 3a6dff6 commit bf66436
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ All Sass files are located within ``/assets/scss``, with the ``style.scss`` outp
###### Default task
All JavaScript files are located with ``/assets/js``, the ``scripts.js`` file is the main Javascript file for the theme, with external third party libraries within the ``vendor`` folder. All files within this will be concatenated into the ``dist/main.js`` file and ``dist/main.min.js``

The scripts task will also run the main JavaScript file through Babel, which means you can use all the new ES2015, ES2016 etc. features without fear of them not working in some older browsers!

* ``/assets/js/scripts.js`` is the main JavaScript file. This is where you should write all of your JavaScript.
* ``/assets/js/dist/main.js`` is the uncompressed and concatenated JavaScript file from all of the files within the ``/assets/js/vendor/*.js`` folder and ``/assets/js/scripts.js`` file.
* ``/assets/js/dist/main.min.js`` is our compressed version of the ``/assets/js/dist/main.js`` file.
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var imagemin = require('gulp-imagemin');
var prefix = require('gulp-autoprefixer');
var svgstore = require('gulp-svgstore');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');

/**
* @function variables
Expand Down Expand Up @@ -50,6 +51,9 @@ var autoprefixerOptions = {
*/
gulp.task('scripts', function () {
return gulp.src([jsFiles, mainJSFile])
.pipe(babel({
presets: ['env']
}))
.pipe(plumber())
.pipe(concat(outputJSFile)) // output main JavaScript file without uglify
.pipe(gulp.dest(outputJSFileLocation))
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
"author": "Ben Brehaut",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"browser-sync": "^2.18.12",
"gulp": "^3.8.8",
"gulp-autoprefixer": "4.0.0",
"gulp-babel": "^7.0.0",
"gulp-clean-css": "^3.6.0",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^3.3.0",
Expand Down

0 comments on commit bf66436

Please sign in to comment.