-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
59 lines (51 loc) · 1.44 KB
/
gulpfile.js
File metadata and controls
59 lines (51 loc) · 1.44 KB
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
var gulp = require('gulp');
var del = require('del');
var argv = require('yargs').argv;
var gulpif = require('gulp-if');
var connect = require('gulp-connect');
var uglify = require('gulp-uglify');
var pleeease = require('gulp-pleeease');
var stylus = require('gulp-stylus');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var webpack = require('gulp-webpack');
var webpackConfig = require('./webpack.config.js');
var port = process.env.PORT || 8080;
var reloadPort = process.env.RELOAD_PORT || 35729;
gulp.task('clean', function () {
return del.sync(['dist']);
});
gulp.task('stylus', function(){
return gulp.src([
'./stylus/*.styl'
])
.pipe(stylus())
.pipe(pleeease())
.pipe(minifyCss({keepSpecialComments: 0}))
.pipe(rename({extname: '.css'}))
.pipe(gulp.dest('./css/'));
});
gulp.task('build', function () {
return gulp.src(webpackConfig.entry.main[0])
.pipe(webpack(webpackConfig))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('dist/'));
});
gulp.task('serve', function () {
connect.server({
port: port,
root: '.',
livereload: {
port: reloadPort
}
});
});
gulp.task('reload-js', function () {
return gulp.src('dist/*.js')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(['dist/*.js'], ['reload-js']);
gulp.watch(['stylus/**/*.styl'],['stylus']);
});
gulp.task('default', ['clean', 'stylus', 'build', 'serve', 'watch']);