-
Notifications
You must be signed in to change notification settings - Fork 25
/
gulpfile.js
98 lines (85 loc) · 3.31 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
'use strict';
var gulp = require ('gulp');
var usemin = require ('gulp-usemin');
var sass = require ('gulp-sass');
var sassGlob = require ('gulp-sass-glob');
var ngAnnotate = require ('gulp-ng-annotate');
var angularFilesort = require ('gulp-angular-filesort');
var mod_rewrite = require ('connect-modrewrite');
var minifyCss = require ('gulp-cssnano');
var uglify = require ('gulp-uglify');
var plumber = require ('gulp-plumber');
var concat = require ('gulp-concat');
var rename = require ('gulp-rename');
var gutil = require ('gulp-util');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var stream = browserSync.stream;
gulp.task ('sass', function () {
return gulp.src ('./src/scss/angular-ui-swiper.scss')
.pipe (plumber())
.pipe (sassGlob())
.pipe (sass().on('error', sass.logError))
.pipe (gulp.dest('./dist/'));
});
gulp.task ('sass:production', function () {
return gulp.src ('./src/scss/angular-ui-swiper.scss')
.pipe (rename('angular-ui-swiper.min.css'))
.pipe (plumber())
.pipe (sassGlob())
.pipe (sass().on('error', sass.logError))
.pipe (minifyCss({discardComments: {removeAll: true}}))
.pipe (gulp.dest('./dist/'));
});
gulp.task ('js', function () {
return gulp.src ('./src/**/*.js')
.pipe (plumber())
.pipe (ngAnnotate().on('error', gutil.log))
.pipe (angularFilesort())
.pipe (concat('angular-ui-swiper.js'))
.pipe (gulp.dest('./dist/'));
});
gulp.task ('js:production', function () {
return gulp.src ('./src/**/*.js')
.pipe (plumber())
.pipe (ngAnnotate().on('error', gutil.log))
.pipe (angularFilesort())
.pipe (concat('angular-ui-swiper.min.js'))
.pipe (uglify().on('error', gutil.log))
.pipe (gulp.dest('./dist/'));
});
// **********************************************************************
// **********************************************************************
// **********************************************************************
// RUNTIME RELATED TASKS
// Stop browser sync
gulp.task('stop', function() {
browserSync.exit();
});
// refreshes the webpage
gulp.task('serve', ['default'], function() {
browserSync.init({
port: 9000,
server : {
baseDir : '.',
// Make sure its getting the index.html file
middleware: [
mod_rewrite([
'^/bower_components/(.*) /bower_components/$1 [L]',
'^(.*)\.(gif|jpg|png|jpeg|css|js|swf|svg|woff.*|woff2.*|ttf.*)$ /$1.$2 [L,NC]',
'^(.*)$ /index.html [NE,L,QSD]'
//'^[^\\.]*$ /index.html [L]'
])
]
},
logLevel : 'debug',
open : true,
browser : 'google chrome'
});
gulp.watch(['src/**/*.js', 'js/**/*.js'], ['js', reload]);
gulp.watch('src/**/*.scss', ['sass', reload]);
gulp.watch('index.html', ['sass', reload]);
gulp.watch('./gulpfile.js', ['stop']);
});
gulp.task ('default', ['sass', 'sass:production', 'js', 'js:production']);
gulp.task ('build', ['default']);