-
Notifications
You must be signed in to change notification settings - Fork 81
/
gulpfile.js
executable file
·70 lines (60 loc) · 1.69 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
68
69
70
const gulp = require('gulp'),
webserver = require('gulp-webserver'),
babel = require('gulp-babel'),
gutil = require('gulp-util'),
sourcemaps = require('gulp-sourcemaps'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
cssnext = require('postcss-cssnext'),
browserSupport = ['last 2 versions', 'ie 10'],
source = 'process/',
dest = 'builds/masteringcode/';
gulp.task('html', function() {
gulp.src(dest + '**/*.html');
});
// Regular CSS
gulp.task('css', function() {
gulp.src(dest + '**/*.css');
});
// Post CSS
gulp.task('postcss', function() {
gulp.src(source + 'postcss/style.css')
.pipe(sourcemaps.init())
.pipe(postcss([
cssnext({ browsers: browserSupport })
]))
.on('error', gutil.log)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'css'));
});
// Sass
gulp.task('sass', function() {
gulp.src(source + 'scss/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(dest + 'css'));
});
// JavaScript ES6
gulp.task('js', function() {
gulp.src(source + 'js/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', gutil.log)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'js'));
});
gulp.task('watch', function() {
gulp.watch(source + '**/*.js', ['js']);
gulp.watch(dest + '**/*.css', ['css']); //CSS
gulp.watch(source + 'postcss/**/*.css', ['postcss']); // PostCSS
gulp.watch(source + 'scss/**/*.scss', ['sass']); // sass
gulp.watch(dest + '**/*.html', ['html']);
});
gulp.task('webserver', function() {
gulp.src(dest)
.pipe(webserver({
livereload: true,
port: 3000,
open: true
}));
});
gulp.task('default', ['html', 'postcss', 'js', 'webserver','watch']);