-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (95 loc) · 2.46 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
/*jshint node: true*/
'use strict';
var gulp = require('gulp'),
preprocess = require('gulp-preprocess'),
del = require('del'),
connect = require('gulp-connect'),
concat = require('gulp-concat'),
less = require('gulp-less'),
rename = require('gulp-rename'),
bower = require('gulp-bower'),
ngAnnotate = require('gulp-ng-annotate'),
minifyJS = require('gulp-uglify'),
minifyCSS = require('gulp-minify-css');
var config = {
dest: './www'
};
var preprocess_config = {
context: {
NODE_ENV: 'production',
DEBUG: true
}
};
/**
* @task clean
* Esta tarefa possui como objetivo limpar o diretório 'build'
*/
gulp.task('clear', function () {
del([config.dest]);
});
/**
* @task connect
* Esta tarefa possui como objetivo iniciar um servidor na pasta 'build'
*/
gulp.task('preview', function () {
connect.server({
root: config.dest,
port: 9000
});
});
/**
* @task bower:copy
* Esta tarefal possui como objetivo copiar as bibliotecas do bower
*/
gulp.task('bower:copy', function () {
bower()
.pipe(gulp.dest(config.dest+ '/bower_components'));
});
/**
* @task build
*/
gulp.task('build', ['clear', 'bower:copy', 'build:data', 'build:html', 'build:less', 'build:js']);
gulp.task('build:data', function() {
gulp.src('./data/**')
.pipe(gulp.dest(config.dest));
});
gulp.task('build:html', function () {
gulp.src('./src/**/*.html')
.pipe(preprocess(preprocess_config))
.pipe(gulp.dest(config.dest));
});
gulp.task('build:less', function () {
gulp.src('./src/less/styles.less')
.pipe(preprocess(preprocess_config))
.pipe(less())
.pipe(gulp.dest(config.dest))
.pipe(minifyCSS())
.pipe(rename('styles.min.css'))
.pipe(gulp.dest(config.dest));
});
gulp.task('build:js', function () {
gulp.src(['./src/**/*.js'])
.pipe(preprocess(preprocess_config))
.pipe(ngAnnotate())
.pipe(concat('main.js'))
.pipe(gulp.dest(config.dest))
.pipe(minifyJS({mangle: true}))
.pipe(rename('main.min.js'))
.pipe(gulp.dest(config.dest));
});
/**
* @task watch
*/
gulp.task('watch', function () {
function watch(filetype) {
gulp.watch('./src/**/*.' + filetype, ['build:' + filetype]);
}
watch('html');
watch('less');
watch('js');
//gulp.watch('./data/**', ['build:data']);
});
/**
* @task default
*/
gulp.task('default', ['build', 'watch', 'preview']);