-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
56 lines (47 loc) · 1.48 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
'use strict';
const babelify = require('babelify');
const browserify = require('browserify');
const gulp = require('gulp');
const connect = require('gulp-connect');
const less = require('gulp-less');
const run = require('gulp-run');
const streamify = require('gulp-streamify');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const vueify = require('vueify');
gulp.task('browserify', () => {
browserify('js/form.js')
.transform(vueify)
.transform(babelify)
.bundle()
.on('error', (err) => console.log('Error parsing with Browserify:', err.message))
.pipe(source('form.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('dist'));
});
gulp.task('less', () => {
gulp.src('less/*.less')
.pipe(less())
.on('error', (err) => console.log('Error parsing LESS:', err.message))
.pipe(gulp.dest('dist'));
});
gulp.task('static', () => {
gulp.src('static/*')
.pipe(gulp.dest('dist'));
});
gulp.task('serve', () => {
connect.server({
root: 'dist',
port: process.env.PORT || 5000
});
});
gulp.task('watch', () => {
gulp.watch(['js/*.js', 'vue/*.vue'], ['browserify']);
gulp.watch('less/*.less', ['less']);
gulp.watch('src/*', ['src']);
});
gulp.task('publish', () => {
run('git subtree push --prefix dist origin gh-pages').exec();
});
gulp.task('build', ['browserify', 'less', 'static']);
gulp.task('default', ['build', 'serve', 'watch']);