Created
February 1, 2016 16:05
-
-
Save sbalay/9b7e944e7aac40c73450 to your computer and use it in GitHub Desktop.
Js gulp task with environment custom settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp'; | |
import uglify from 'gulp-uglify'; | |
import eslint from 'gulp-eslint'; | |
import babel from 'gulp-babel'; | |
import concat from 'gulp-concat'; | |
import sourcemaps from 'gulp-sourcemaps'; | |
import gulpif from 'gulp-if'; | |
import globalConfig from './config'; | |
const taskOptions = globalConfig.getConfigKeys(); | |
const localConfig = { | |
src: './src/js/**/*.js', | |
dest: './build/js/', | |
buildFileName: 'all.js' | |
}; | |
gulp.task('js', () => | |
gulp.src(localConfig.src) | |
.pipe(gulpif(taskOptions.lint, eslint())) | |
.pipe(gulpif(taskOptions.lint, eslint.format())) | |
.pipe(gulpif(taskOptions.sourcemaps, sourcemaps.init())) | |
.pipe(babel()) | |
.pipe(gulpif(taskOptions.concat, concat(localConfig.buildFileName))) | |
.pipe(gulpif(taskOptions.minify, uglify())) | |
.pipe(gulpif(taskOptions.sourcemaps, sourcemaps.write())) | |
.pipe(gulp.dest(localConfig.dest)) | |
); | |
gulp.task('build', ['js', 'css', 'vendor']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment