This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
gulpfile.js
113 lines (101 loc) · 2.95 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
/*
* CartrolandoFC (http://cartrolandofc.cf)
* Developed by WGenial (http://wgenial.com.br)
*/
// Includes and Plug-ins
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var cssmin = require('gulp-cssmin');
var sourcemaps = require('gulp-sourcemaps');
var notify = require('gulp-notify');
var watch = require('gulp-watch');
var bower = require('gulp-bower');
var folder_bower = "bower_components";
var replace = require('gulp-replace');
var copy = require('gulp-copy');
var del = require('del');
var replace = require('gulp-replace');
var autoprefixer = require('gulp-autoprefixer');
var ngAnnotate = require('gulp-ng-annotate');
var inject = require('gulp-inject');
// Javascripts files
var javascript_files = [
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/angular/angular.js',
'bower_components/angularUtils-pagination/dirPagination.js',
'src/js/estatisticas.js',
'src/js/scripts.js',
];
// CSS files
var css_files = [
'bower_components/bootstrap/dist/css/bootstrap.css',
'src/css/style.css',
'src/css/team.css',
'src/css/responsive.css'
];
// HTML files
var html_files = [
'index.html',
'parciais-rodada.html',
'estatisticas.html'
];
// Cleanup files
gulp.task('cleanup', function() {
del(['./**/.DS_Store']);
});
// Javascript Tasks
gulp.task('js', ['cleanup'], function() {
var timestamp = Math.round(new Date()/1000);
var filename = 'scripts-'+ timestamp +'.min.js';
gulp
.src(javascript_files)
.pipe(ngAnnotate())
.pipe(concat(filename))
.pipe(uglify())
.pipe(gulp.dest('build/js'))
.pipe(notify({message: 'Javascript - tasks completed'}))
// reset build
del(['build/js/*']);
return gulp.src(html_files, { base: './' })
.pipe(replace(/<script src="\/build\/js\/.*>/g,'<script src="/build/js/'+ filename +'" type="text/javascript"></script>'))
.pipe(gulp.dest('./'));
});
// CSS Tasks
// Main tasks
gulp.task('css', ['cleanup'], function() {
var timestamp = Math.round(new Date()/1000);
var filename = 'styles-'+ timestamp +'.min.css';
gulp
.src(css_files)
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(concat(filename))
.pipe(sourcemaps.init())
.pipe(cssmin())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/css'))
.pipe(notify({message: 'CSS - tasks completed'}));
// reset build
del(['build/css/*']);
return gulp.src(html_files, { base: './' })
.pipe(replace(/<link href="\/build\/css\/.*>/g,'<link href="/build/css/'+ filename +'" rel="stylesheet" type="text/css">'))
.pipe(gulp.dest('./'));
});
// Watch JS and CSS files
gulp.task('watch', function() {
gulp.watch(javascript_files, ['js']);
gulp.watch(css_files, ['css']);
});
// Bower tasks
gulp.task('bower-clean', function() {
del(['build/','bower_components/']);
});
gulp.task('bower', ['bower-clean'], function() {
bower().pipe(gulp.dest('bower_components'));
});
// Default task
gulp.task('default', ['watch']);