-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
168 lines (160 loc) · 5.65 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
var gulp = require('gulp'),
connect = require('gulp-connect'),
ngrok = require('ngrok'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
runSequence = require('run-sequence'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync'),
modRewrite = require('connect-modrewrite'),
ejs = require('gulp-ejs'),
ngAnnotate = require('gulp-ng-annotate'),
browserify = require('gulp-browserify'),
source = require('vinyl-source-stream');
gulp.task('connect', function(){
browserSync({
server: {
baseDir: "front/",
middleware: [modRewrite(['!\\.\\w+$ /index.html [L]'])]
},
port: 8888,
open: false
});
ngrok.connect(8888, function(error, url) {
console.log('[ngrok] ' + url);
});
});
gulp.task('sass', function(){
gulp.src(['./front/scss/awesome/_font-awesome.scss', './front/scss/foundation/*.scss', './front/scss/layout/*.scss', './front/scss/object/**/*.scss'])
.pipe(plumber({errorHandler: notify.onError('<%= error.message %>')}))
.pipe(concat('application.scss'))
.pipe(sass())
.pipe(gulp.dest('./front/css'));
});
gulp.task('js', function(){
gulp.src(['./front/js/_balloon.js', './front/js/_config.js', './front/js/controller/*.js', './front/js/directive/*.js', './front/js/service/*.js'])
.pipe(plumber({errorHandler: notify.onError('<%= error.message %>')}))
.pipe(concat('application.js'))
.pipe(browserify())
.pipe(gulp.dest('front/js'));
});
gulp.task('js:build', function(){
gulp.src(['./front/js/_balloon.js', './front/js/controller/*.js', './front/js/directive/*.js', './front/js/service/*.js'])
.pipe(plumber())
.pipe(concat('application.min.js'))
.pipe(browserify())
.pipe(gulp.dest('front/js'));
});
gulp.task('copy', function(){
gulp
.src(['./front/css/**'])
.pipe(gulp.dest('./public/css'));
gulp
.src(['./front/js/**'])
.pipe(gulp.dest('./public/js'));
gulp
.src(['./front/img/**'])
.pipe(gulp.dest('./public/img/'));
gulp
.src(['./front/template/**'])
.pipe(gulp.dest('./public/template/'));
gulp
.src(['./front/fonts/**'])
.pipe(gulp.dest('./public/fonts/'));
gulp
.src(['./front/parts/**'])
.pipe(gulp.dest('./public/parts/'));
/***** Public *****/
gulp
.src(['./front/template/public/index.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/top/'));
gulp
.src(['./front/template/public/products/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/products/'));
gulp
.src(['./front/template/public/carts/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/carts/'));
/***** Admin *****/
gulp
.src(['./front/template/admin/index.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin/'));
gulp
.src(['./front/template/admin/products/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin_products/'));
gulp
.src(['./front/template/admin/products/edit.html'])
.pipe(rename('new.html.erb'))
.pipe(gulp.dest('./app/views/admin_products/'));
gulp
.src(['./front/template/admin/orders/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin_orders/'));
gulp
.src(['./front/template/admin/categories/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin_categories/'));
gulp
.src(['./front/template/admin/customers/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin_customers/'));
gulp
.src(['./front/template/admin/mails/index.html'])
.pipe(rename('edit.html.erb'))
.pipe(gulp.dest('./app/views/admin_mails/'));
gulp
.src(['./front/template/admin/contacts/*.html'])
.pipe(rename(function(path) {
path.extname = '.html.erb';
}))
.pipe(gulp.dest('./app/views/admin_contacts/'));
gulp
.src(['./front/template/admin/settings/*.html'])
.pipe(rename('index.html.erb'))
.pipe(gulp.dest('./app/views/admin_users/'));
gulp
.src(['./front/template/admin/login.html'])
.pipe(rename('new.html.erb'))
.pipe(gulp.dest('./app/views/sessions/'));
});
gulp.task('ejs', function(){
gulp
.src(['./front/ejs/**/*.ejs', '!./front/ejs/**/_*.ejs'])
.pipe(ejs())
.pipe(gulp.dest('./front/template/'));
});
gulp.task('watch', function(){
gulp.watch(['front/scss/**/*.scss'], ['sass']);
gulp.watch(['front/js/**/_*.js'], ['js']);
gulp.watch(['front/ejs/**/*.ejs'], ['ejs']);
gulp.watch(['front/index.html', 'front/ejs/**/*.ejs', 'front/css/application.css', 'front/js/application.js'], function(){
browserSync.reload();
});
});
gulp.task('default', ['sass', 'js', 'ejs', 'connect', 'watch']);
gulp.task('build', function(){
runSequence('sass', 'js:build', 'ejs', 'copy');
});