-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·67 lines (66 loc) · 2.1 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Initialize Gulp
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
livereload = require('gulp-livereload'),
webserver = require('gulp-webserver');
gulp.task('default', ['styles','scripts','html']);
gulp.task('styles', function() {
return gulp.src('_resources/scss/app.scss')
// Run the SASS compiler and autoprefixer
.pipe(sass({ style: 'compact', 'sourcemap=none': true}))
.on('error', function (error) {
console.error(error);
this.emit('end');
})
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 9', 'ios 6', 'android 4'))
.pipe(gulp.dest('_resources/css'))
.pipe(notify({ message: 'Outputted compiled CSS file' }))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('_resources/css'))
.pipe(notify({ message: 'Outputted Minified CSS.' }))
.pipe(livereload())
.pipe(notify({ message: 'Style task completed.' }));
});
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
// with sourcemaps all the way down
return gulp.src('_resources/js/**/*.js')
.pipe(sourcemaps.init())
.pipe(concat('all.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('_resources/minjs'))
.pipe(livereload());
});
gulp.task('html', function() {
return gulp.src('**/*.html')
.pipe(livereload());
});
// Initialize the Watch Task
gulp.task('watch', function() {
livereload.listen();
gulp.watch('**/*.html', ['html']);
gulp.watch('_resources/js/**/*.js', ['scripts']);
var watcher = gulp.watch(['_resources/scss/*.scss'], ['styles']);
watcher.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
gulp.task('server', function() {
gulp.src('./')
.pipe(webserver({
port: 8081,
host: 'localhost',
fallback: 'index.html',
livereload: true,
open: true
}))
;
});