-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (56 loc) · 1.59 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
'use strict';
/*====================================
= bower & sass =
====================================*/
var gulp = require('gulp');
var bower = require('gulp-bower');
var sass = require('gulp-sass');
gulp.task('bower', function() {
return bower('./public/lib/');
});
gulp.task('sass', function() {
return gulp.src('./app/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/css'));
});
gulp.task('sass:watch', function() {
gulp.watch('./app/sass/**/*.scss', ['sass']);
});
/*==========================================
= Move Static Files =
==========================================*/
var cssmin = require('gulp-cssmin');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var file_static_css = [
'./app/css/component.css',
'./app/css/style.css',
];
var file_static_js = [
'./app/js/main.js'
];
gulp.task('move', function() {
for (var i in file_static_css) {
gulp.src(file_static_css[i])
.pipe(cssmin())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/css'));
}
for (var i in file_static_js) {
gulp.src(file_static_js[i])
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/js'));
}
});
gulp.task('move:watch', function() {
for (var i in file_static_css) {
gulp.watch(file_static_css[i], ['move']);
}
for (var i in file_static_js) {
gulp.watch(file_static_js[i], ['move']);
}
});
gulp.task('watch', ['sass', 'sass:watch', 'move', 'move:watch']);
gulp.task('default', ['bower', 'sass', 'move']);