-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·94 lines (85 loc) · 1.88 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
'use strict';
/**
* Import node modules
*/
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var babelify = require('babelify');
var browser_sync = require( 'browser-sync' );
/**
* ES6 to ES5
*/
gulp.task('js', function() {
return browserify({
entries: 'src/js/app.js'
})
.transform('babelify', {presets: ['es2015']})
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(gulp.dest('assets/js/'));
} );
/**
* Sass to CSS
*/
gulp.task('sass', function() {
return gulp.src('src/scss/**/*.scss')
.pipe(sass({
outputStyle: 'expanded'
}))
.pipe(gulp.dest('assets/css/'))
.pipe(postcss([autoprefixer({
browsers: ['last 2 versions'],
cascade: false
})]))
.pipe(gulp.dest('assets/css/'))
.pipe(postcss([cssnano()]))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('assets/css/'));
});
/**
* Auto Compile Sass.
*/
gulp.task('watch', function() {
gulp.watch(['src/scss/**/*.scss'], ['sass']);
gulp.watch(['src/js/**.js'], ['js']);
});
/**
* Browsersync
*/
gulp.task('browsersync', function() {
browser_sync.init( {
server: {
baseDir: "./"
},
files: [
'./**.html',
'./assets/**'
]
});
});
/**
* Deploy GitHub Pages
*/
gulp.task('deploy_gh_pages', ['build'], function() {
return gulp.src(
[
'./assets/**',
'./index.html',
'./*.md'
],
{base: './'}
)
.pipe(gulp.dest('gh-pages'));
});
gulp.task('build', ['sass', 'js']);
gulp.task('default', ['build', 'browsersync', 'watch']);