Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const gulp = require('gulp');
- const babel = require('gulp-babel');
- const argv = require('yargs').argv;
- const jsSrc = 'src/**/*.js';
- const jsonSrc = 'src/*.json';
- const dist = 'dist';
- // Transpile from ES6 to ES5
- gulp.task( 'transpile', () => {
- return gulp
- .src( jsSrc )
- .pipe( babel( {
- presets: [ 'es2015' ]
- }))
- .pipe( gulp.dest( dist ) );
- });
- // Copy JSON files
- gulp.task( 'copy-json-files', () => {
- return gulp
- .src( jsonSrc )
- .pipe( gulp.dest( dist ) )
- });
- // Check if --watch true was passed to the command line
- if( typeof argv.watch !== 'undefined' && !!argv.watch ){
- console.log('Watching enabled!');
- gulp.task('default',[ 'transpile' ], () => {
- return gulp.watch( jsSrc, ['transpile']);
- });
- gulp.task('default',[ 'copy-json-files' ], () => {
- return gulp.watch( jsonSrc, ['copy-json-files']);
- });
- }
- else {
- gulp.task('default',[ 'transpile', 'copy-json-files' ]);
- }
Advertisement
Add Comment
Please, Sign In to add comment