-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
145 lines (130 loc) · 3.67 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var gulp = require('gulp');
var dest = gulp.dest;
var wrap = require('gulp-insert').wrap;
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
var templateCache = require('gulp-angular-templatecache');
var autoprefixer = require('gulp-autoprefixer');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
//var imagemin = require('gulp-imagemin');
var dst = 'build';
var paths = {
css: {
index: {},
param: [
'css/*.css',
'../bower_components/sweetalert/lib/sweet-alert.css',
'modules/**/*.css'
]
},
fonts: {
index: ['icomoon.ttf'],
param: ['icomoon.ttf']
},
other: {
param: [
'index.html',
'globals.sht'
]
}
}
gulp.task('app', ['css'], function() {
/*COPY FONTS*/
gulp.src(paths.fonts['param'], {cwd: './frontend/css/fonts'})
.pipe(dest('./' + dst + '/css/fonts'));
gulp.src(['./**'], {cwd: './frontend/img'})
.pipe(dest('./' + dst + '/img'));
/*COPY OTHER*/
gulp.src(paths.other['param'], {cwd: './frontend'}).pipe(dest('./' + dst));
});
gulp.task('css', function() {
gulp.src(paths.css['param'], {cwd: './frontend'})
.pipe(concat('param.min.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
//.pipe(uglify())
.pipe(dest('./' + dst + '/css'));
global._needsReload = true;
});
gulp.task('bfy-angular', function() {
var angular = browserify();
angular.require('./frontend/external.js', {expose: 'angular'});
angular = angular.bundle();
angular
.pipe(source('./external.js'))
.pipe(dest('./' + dst));
});
gulp.task('bfy-scripts', ['ng-templates'], function() {
var index;
index = browserify('./frontend/index.js');
index.external('angular');
index.external('templates');
[
'app', './frontend/modules/app.js',
'xmls', './frontend/modules/xmls.js',
'menu', './frontend/modules/menu.js',
'globals', './frontend/modules/globals.js',
'proxy', './frontend/modules/proxy.js'
].forEach(function(link, i, a) {
if (i%2) index.require(link, {expose: a[i-1]});
});
index = index.bundle();
index
.pipe(source('./index.js'))
//.pipe(streamify(uglify()))
.pipe(dest('./' + dst)).on('end', function() {
global._needsReload = true;
});
});
gulp.task('ng-templates', function() {
gulp.src(['modules/**/*.template'], {cwd: './frontend'})
.pipe(templateCache())
.pipe(wrap(
'angular.module("templates", []);\r\n',
'\r\nmodule.exports = "templates";'))
.pipe(dest('./' + dst)).on('end', function() {
var templates = browserify();
templates.require('./' + dst + '/templates.js', {expose: 'templates'})
templates.bundle()
.pipe(source('./templates.js'))
.pipe(dest('./' + dst))
.on('end', function() {
global._needsReload = true;
});
});
});
gulp.task('default', ['bfy-angular', 'bfy-scripts', 'app']);
gulp.task('server', ['default'], function() {
var server = require(__dirname + '/server.js');
gulp.watch([
'index.js',
'modules/*.js',
'modules/*/**.js'
],
{cwd: './frontend/'},
['bfy-scripts']
);
gulp.watch([
'modules/**/*.template'
],
{cwd: './frontend/'},
['ng-templates']
);
gulp.watch(
paths.css.param,
{cwd: './frontend/'},
['css']
);
paths.other.param.forEach(function(target) {
gulp.watch(target, {cwd: './frontend/'}, function() {
gulp.src(target, {cwd: './frontend'})
.pipe(dest('./' + dst));
global._needsReload = true;
});
});
});