-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·56 lines (47 loc) · 1.45 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var $ = require('gulp-load-plugins')();
var webpack = require('webpack');
var del = require('del');
var run = require('run-sequence');
var paths = {
src: './src',
dist: './dist',
};
gulp.task('webpack', function(callback) {
webpack(require('./webpack.config'), function(err) {
if (err) { throw new gutil.PluginError('webpack', err); }
callback();
});
});
gulp.task('jade', function() {
return gulp.src(paths.src + '/views/index.jade')
.pipe($.plumber())
.pipe($.jade({ data: require(paths.src + '/views/data') }))
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy:images', function() {
return gulp.src(paths.src + '/assets/**/*.{jpg,jpeg,png,gif}', { base: paths.src })
.pipe($.imagemin())
.pipe(gulp.dest(paths.dist));
});
gulp.task('copy:assets', function() {
return gulp.src([
paths.src + '/assets/**/*',
paths.src + '/CNAME',
paths.src + '/favicon.ico',
], { base: paths.src })
.pipe(gulp.dest(paths.dist));
});
gulp.task('clean', function() {
return del(paths.dist + '/**/*');
});
gulp.task('build', ['clean'], function(callback) {
run(['jade', 'webpack', 'copy:assets'], callback);
});
gulp.task('watch', ['build'], function() {
gulp.watch(paths.src + '/scripts/**/*.js', ['webpack']);
gulp.watch(paths.src + '/styles/**/*.{styl,css,woff}', ['webpack']);
gulp.watch(paths.src + '/views/**/*', ['jade']);
});
gulp.task('default', ['build']);