Skip to content

Commit

Permalink
Babelize build/ js files only
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo-Zanutta committed Jun 24, 2016
1 parent 9c5527f commit 713ca22
Show file tree
Hide file tree
Showing 6 changed files with 691 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config.json
Expand Up @@ -8,6 +8,8 @@
"autoprefixer_options": {
"browsers": ["last 3 versions", "ie > 9", "and_chr >= 2.3"]
},
"js_build_src": "./src/js/build/**/*.js",
"js_vendor_src": "./src/js/vendor/**/*.js",
"js_src": ["./src/js/vendor/**/*.js", "./src/js/build/**/*.js"],
"js_file_name": "application.js",
"js_dest": "./src/js"
Expand Down
17 changes: 11 additions & 6 deletions gulpfile.babel.js
Expand Up @@ -14,6 +14,7 @@ import gulpLoadPlugins from 'gulp-load-plugins';
import browserSync from 'browser-sync';
import del from 'del';
import runSequence from 'run-sequence';
import merge from 'merge2';
import { argv } from 'yargs';

const $ = gulpLoadPlugins();
Expand All @@ -37,16 +38,20 @@ gulp.task('styles', () => {
.pipe(gulp.dest(config.sass_dest))
});

// Concat, sourcemaps and minify js files
// Concat, babelify, sourcemaps and minify js files
gulp.task('scripts', () => {
gulp.src(config.js_src)
return merge(
gulp.src(config.js_vendor_src)
.pipe($.size({title: 'Vendor scripts'})),
gulp.src(config.js_build_src)
.pipe($.babel())
)
.pipe($.if(argv.pretty, $.sourcemaps.init()))
.pipe($.babel())
.pipe($.concat(config.js_file_name))
.pipe($.if(!argv.pretty, $.uglify({preserveComments: 'some'})))
.pipe($.if(argv.pretty, $.sourcemaps.write('.')))
.pipe($.if(argv.pretty, $.sourcemaps.write('./')))
.pipe($.size({title: 'Scripts'}))
.pipe(gulp.dest(config.js_dest))
.pipe(gulp.dest(config.js_dest));
});

// Clean the dist/ folder
Expand All @@ -56,7 +61,7 @@ gulp.task('clean', () => {
])
});

// Copy the content from the src/ folder to the dist/ one
// Copy the content from src/ to dist/
gulp.task('copy', ['clean'], () => {
return gulp.src(config.src_folder)
.pipe($.size({title: 'Copying ./src content in ./dist'}))
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"gulp-task-listing": "^1.0.1",
"gulp-uglify": "^1.5.3",
"gulp-util": "^3.0.7",
"merge2": "^1.0.2",
"run-sequence": "^1.1.5",
"yargs": "^4.3.2"
}
Expand Down

0 comments on commit 713ca22

Please sign in to comment.