-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
119 lines (94 loc) · 3.05 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict'
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var mainBowerFiles = require('main-bower-files');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var del = require('del');
var runSequence = require('run-sequence');
var replace = require('gulp-replace');
var runSeq = require('run-sequence');
var server = require('gulp-express');
gulp.paths = {
dist: 'dist',
};
var paths = gulp.paths;
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function () {
browserSync.init({
server: "./"
});
gulp.watch('scss/**/*.scss', ['sass']);
gulp.watch('**/*.html').on('change', browserSync.reload);
gulp.watch('js/**/*.js').on('change', browserSync.reload);
});
gulp.task("heroku:production", function () {
runSeq('serve')
});
// Static Server without watching scss files
gulp.task('serve:lite', function () {
browserSync.init({
server: "./"
});
gulp.watch('**/*.css').on('change', browserSync.reload);
gulp.watch('**/*.html').on('change', browserSync.reload);
gulp.watch('js/**/*.js').on('change', browserSync.reload);
});
gulp.task('sass', function () {
return gulp.src('./scss/style.scss')
.pipe(sass())
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
});
gulp.task('sass:watch', function () {
gulp.watch('./scss/**/*.scss');
});
gulp.task('clean:dist', function () {
return del(paths.dist);
});
gulp.task('copy:bower', function () {
return gulp.src(mainBowerFiles(['**/*.js', '!**/*.min.js']))
.pipe(gulp.dest(paths.dist + '/js/libs'))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.dist + '/js/libs'));
});
gulp.task('copy:css', function () {
return gulp.src('./css/**/*')
.pipe(gulp.dest(paths.dist + '/css'));
});
gulp.task('copy:img', function () {
return gulp.src('./img/**/*')
.pipe(gulp.dest(paths.dist + '/img'));
});
gulp.task('copy:fonts', function () {
return gulp.src('./fonts/**/*')
.pipe(gulp.dest(paths.dist + '/fonts'));
});
gulp.task('copy:js', function () {
return gulp.src('./js/**/*')
.pipe(gulp.dest(paths.dist + '/js'));
});
gulp.task('copy:views', function () {
return gulp.src('./views/**/*')
.pipe(gulp.dest(paths.dist + '/views'));
});
gulp.task('copy:html', function () {
return gulp.src('index.html')
.pipe(gulp.dest(paths.dist + '/'));
});
gulp.task('replace:bower', function () {
return gulp.src([
'./dist/**/*.html',
'./dist/**/*.js',
], { base: './' })
.pipe(replace(/bower_components+.+(\/[a-z0-9][^/]*\.[a-z0-9]+(\'|\"))/ig, 'js/libs$1'))
.pipe(gulp.dest('./'));
});
gulp.task('build:dist', function (callback) {
runSequence('clean:dist', 'copy:bower', 'copy:css', 'copy:img', 'copy:fonts', 'copy:js', 'copy:views', 'copy:html', 'replace:bower', callback);
});
gulp.task('default', ['serve']);