-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
59 lines (52 loc) · 1.52 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
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
del = require('del');
var gulpIgnore = require('gulp-ignore');
var gulpUtil = require('gulp-util');
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts');
});
// Scripts
gulp.task('scripts', function() {
return gulp.src([
'src/scripts/jquery-1.11.3.min.js',
'src/scripts/jquery-i18next.js',
'src/scripts/jquery.timeago.js',
'src/scripts/vue.min.js',
'src/scripts/lazyload.js',
'src/scripts/*.js'])
.pipe(concat('main.js'))
.pipe(gulpIgnore.exclude([ "**/*.map" ]))
.pipe(uglify().on('error', gulpUtil.log))
.pipe(gulp.dest('dist/scripts'))
.pipe(notify({ message: 'Scripts task complete' }));
});
// Styles
gulp.task('styles', function() {
return gulp.src('src/styles/*.css')
.pipe(autoprefixer('last 2 version'))
.pipe(minifycss())
.pipe(concat('main.css'))
.pipe(gulp.dest('dist/styles'))
.pipe(notify({ message: 'Styles task complete' }));
});
// Clean
gulp.task('clean', function(cb) {
del(['dist/'], cb)
});
gulp.task('watch', function() {
// 看守 .scss 檔
gulp.watch('src/styles/*.css', ['styles']);
// 看守 .js 檔
gulp.watch('src/scripts/*.js', ['scripts']);
});