-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gulpfile.js
73 lines (61 loc) · 1.92 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
var browser = require('browser-sync');
var del = require('del');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var listGulpTasks = require('gulp-task-listing');
var sync = require('run-sequence');
var todo = require('gulp-todoist');
var webpack = require('webpack-stream');
var paths = {
app: ['client/app/**/*.{js,styl,html,json}', 'client/styles/**/*.styl'],
dest: 'dist',
entry: 'client/app/app.js',
html: ['client/index.html', 'client/app/**/*.html'],
js: 'client/app/**/*!(.spec.js).js',
styl: ['client/app/**/*.styl', 'client/style/**/*.styl'],
toCopy: ['client/index.html', 'client/**/*.{jpg,png,ico,svg}', 'client/db.json']
};
gulp.task('build', ['todo'], function() {
return gulp.src(paths.entry)
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest(paths.dest));
});
gulp.task('clean', function() {
return del(['dist/**/*.*', 'dist/img', 'generated']);
});
gulp.task('copy', function() {
return gulp.src(paths.toCopy, { base: 'client' })
.pipe(gulp.dest(paths.dest));
});
gulp.task('lint', function() {
return gulp.src('client/app/**/*.js')
.pipe(eslint({'useEslintrc': true}))
.pipe(eslint.formatEach('stylish', process.stderr))
.pipe( eslint.failAfterError() );
});
gulp.task('ls', listGulpTasks);
gulp.task('serve', function() {
browser({
port: process.env.PORT || 4500,
open: false,
ghostMode: false,
server: {
baseDir: 'dist'
}
});
});
gulp.task('todo', function() {
return gulp.src(paths.js)
.pipe(todo({silent: false, verbose: true}));
});
gulp.task('watch', function() {
gulp.watch(paths.app, ['build', browser.reload]);
gulp.watch(paths.toCopy, ['copy', browser.reload]);
});
//______________________________________________________________________________
gulp.task('default', function(done) {
sync('dist', 'serve', 'watch', done);
});
gulp.task('dist', function(done) {
sync('clean', 'build', 'copy', done);
});