This repository has been archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
/
gulpfile.js
77 lines (63 loc) · 1.82 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
/*
* @Author: dmyang
* @Date: 2015-06-16 15:19:59
* @Last Modified by: dmyang
* @Last Modified time: 2016-11-01 15:39:40
*/
'use strict';
let gulp = require('gulp')
let webpack = require('webpack')
let gutil = require('gulp-util')
let webpackConf = require('./configs/webpack.prod.config')
// let webpackDevConf = require('../configs/webpack.dev.config')
let src = process.cwd() + '/src'
let assets = process.cwd() + '/assets'
// js check
gulp.task('hint', () => {
let jshint = require('gulp-jshint')
let stylish = require('jshint-stylish')
return gulp.src([
'!' + src + '/js/lib/**/*.js',
src + '/js/**/*.js'
])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
})
// clean assets
gulp.task('clean', ['hint'], () => {
let clean = require('gulp-clean')
return gulp.src(assets, {read: true}).pipe(clean())
})
// run webpack pack
gulp.task('pack', ['clean'], (done) => {
webpack(webpackConf, (err, stats) => {
if(err) throw new gutil.PluginError('webpack', err)
gutil.log('[webpack]', stats.toString({colors: true}))
done()
})
})
// html process
gulp.task('default', ['pack'])
/*gulp.task('default', ['pack'], () => {
let replace = require('gulp-replace')
let htmlmin = require('gulp-htmlmin')
return gulp
.src(assets + '/*.html')
// @see https://github.com/kangax/html-minifier
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest(assets))
})*/
// deploy assets to remote server
gulp.task('deploy', () => {
let sftp = require('gulp-sftp')
return gulp.src(assets + '/**')
.pipe(sftp({
host: '[remote server ip]',
remotePath: '/www/app/',
user: 'foo',
pass: 'bar'
}))
})