Created
September 7, 2017 07:23
-
-
Save aosteraas/6ee968c9ccc17556e8491f51748e4e6c to your computer and use it in GitHub Desktop.
This file contains 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
'use strict'; | |
const gulp = require('gulp'); | |
const sass = require('gulp-sass'); | |
const sourcemaps = require('gulp-sourcemaps'); | |
const autoprefix = require('gulp-autoprefixer'); | |
const notify = require('gulp-notify'); | |
const concat = require('gulp-concat'); | |
const order = require('gulp-order'); | |
const uglify = require('gulp-uglify'); | |
const pump = require('pump'); | |
const jshint = require('gulp-jshint'); | |
const paths = { | |
webroot: './wwwroot', | |
cssIn: './Styles/**/*.scss', | |
cssOut: './wwwroot/css', | |
jsIn: './Scripts/**/*.js', | |
jsOut: './wwwroot/js', | |
jsLintable: './Scripts/site/*.js' | |
} | |
const autoprefixOptions = { | |
browsers: ['last 2 versions'] | |
}; | |
gulp.task('css', () => { | |
gulp.src('./Styles/styles.scss') | |
.pipe(sourcemaps.init()) | |
.pipe(autoprefix(autoprefixOptions)) | |
.pipe(sass({outputStyle: 'compressed'})) | |
.pipe(sourcemaps.write('/sourcemaps')) | |
.pipe(gulp.dest(paths.cssOut)); | |
}); | |
gulp.task('jslint', () => { | |
gulp.src(paths.jsLintable) | |
.pipe(jshint({ | |
browser: true, | |
curly: true, | |
devel: true, | |
eqeqeq: true, | |
globals: { | |
jQuery: true, | |
}, | |
strict: "implied", // lint *as if* all files have use strict in top | |
undef: true, | |
unused: "vars" // only check for vars, not func params, disable with /* jshint unused:false */ | |
// Note: some vars (generally jQ$s) are explicty set but never used to make it | |
// more obvious what jQ element is being effected by the call at the end | |
})) | |
.pipe(jshint.reporter('jshint-stylish')); | |
}); | |
gulp.task('js', ['jslint'], () => { | |
pump([ | |
gulp.src(paths.jsIn), | |
sourcemaps.init(), | |
order([ | |
'/Scripts/site/site-utils.js' | |
], { base: '.' }), | |
uglify({ mangle: false }), | |
concat('scripts.min.js'), | |
sourcemaps.write('/sourcemaps'), | |
gulp.dest(paths.jsOut) | |
]); | |
}); | |
gulp.task('watch', ['css', 'js'], () => { | |
gulp.watch(paths.cssIn, ['css']); | |
gulp.watch(paths.jsIn, ['js']); | |
}); | |
gulp.task('default', ['watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment