-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
87 lines (74 loc) · 2.01 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
var gulp = require('gulp');
var open = require('open');
var connect = require('gulp-connect');
var del = require('del');
var glob = require('glob');
var runSequence = require('run-sequence');
var uglifyjs = require('gulp-uglifyjs');
var postcss = require('gulp-postcss');
var plumber = require('gulp-plumber');
var to5 = require('gulp-6to5');
var to5options = {
loose: 'all'
};
var paths = {
sourceBase: './src/',
destBase: './app/'
};
gulp.task('server', function() {
var serverOptions = {
root: paths.destBase,
host: 'localhost',
livereload: false,
port: 9000
};
connect.server(serverOptions);
open('http://localhost:' + serverOptions.port);
});
gulp.task('clean', ['clean:css', 'clean:scripts', 'clean:html']);
gulp.task('clean:css', function(cb) {
del([paths.destBase + '/*.css'], {
force: true
}, cb);
});
gulp.task('clean:scripts', function(cb) {
del([paths.destBase + '/*.js'], {
force: true
}, cb);
});
gulp.task('clean:html', function(cb) {
del([paths.destBase + '/*.html'], {
force: true
}, cb);
});
gulp.task('css', function() {
var processors = [
require('autoprefixer-core'),
require('postcss-custom-properties')(),
require('postcss-nested'),
require('csswring').postcss,
];
return gulp.src(['styles.css'])
.pipe(postcss(processors))
.pipe(gulp.dest(paths.destBase))
.pipe(connect.reload());
});
gulp.task('script', function() {
return gulp.src('script.js')
.pipe(plumber())
.pipe(to5(to5options))
.pipe(uglifyjs('script.js'))
.pipe(gulp.dest(paths.destBase))
.pipe(connect.reload());
});
gulp.task('html', function() {
return gulp.src('index.html')
.pipe(gulp.dest(paths.destBase))
.pipe(connect.reload());
});
gulp.task('build', ['clean'], function(cb) {
runSequence('css', 'script', 'html', cb);
});
gulp.task('default', ['build'], function(cb) {
runSequence('server', cb);
});