Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
347 lines (264 loc) · 7.13 KB
/
Copy pathgulpfile.js
File metadata and controls
347 lines (264 loc) · 7.13 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/*--- Gulp Tasks for app builds ---*/
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
gutil = require('gulp-util'),
minify = require('gulp-clean-css'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
browserSync = require('browser-sync').create();
// Set up global paths objects
var paths = {
root: 'app',
scss: 'app/scss/*.scss',
css: 'app/css/*.css',
views: 'app/*.html',
js: 'app/js/*.js',
output: './dist'
};
var viewGlobs = ['app/scss/*.scss', 'app/*.html'];
var imageGlobs = ['app/images/*.jpg', 'app/images/*.png'];
// App server task
gulp.task('launch-app', () => {
browserSync.init({
server: 'app'
});
// Live reload watcher
//gulp.watch(viewGlobs, ['sassify']).on('change', browserSync.reload);
gulp.watch('app/scss/*.scss', ['sassify']);
gulp.watch('app/*.html').on('change', browserSync.reload);
});
// Watcher task
gulp.task('watchman', ['sassify'], () => {
gulp.watch(paths.scss, ['sassify']);
});
// Compile Scss files
gulp.task('sassify', () => {
return gulp.src(paths.scss)
.pipe(sass())
.pipe(gulp.dest('app/css'));
});
// Minify css files
gulp.task('crunchcss', () => {
gulp.src(paths.css)
.pipe(minify({debug: true}, (details) => {
console.log(details.name + ': ' + details.stats.originalSize);
console.log(details.name + ': ' + details.stats.minifiedSize);
}))
.pipe(gulp.dest(paths.output))
});
// Rename dist Files
gulp.task('rename', ['crunchcss'], () => {
gulp.src(paths.css)
.pipe(rename((path) => {
path.dirname += '/renamed';
path.basename += '';
path.extname = '.min.css';
}))
.pipe(gulp.dest('renamed'))
});
// Optimize images
gulp.task('imagemin', () => {
gulp.src(imageGlobs)
.pipe(imagemin())
.pipe(gulp.dest(paths.output))
});
// Concatinate JS files
gulp.task('concat', () => {
gulp.src(paths.js)
.pipe(concat())
.pipe(gulp.dest())
});
// Gulp BrowserSync Server
/*gulp.task('launch', function(){
browserSync.init({
server: '/app'
});
// Generic watcher tasks
gulp.watch('app/scss/*.scss', ['sassify']);
gulp.watch('app/*.html').on('change', browserSync.reload);
});
// Compile Scss files
gulp.task('sassify', function(){
return gulp.src('app/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('app/css'));
});
// Generic file watcher
/*gulp.task('watchman', function(){
});*/
// Watcher for scss files
/*gulp.task('watchsass', function(){
gulp.watch(paths.scss, ['sassify']);
});
// Minify compiled files
gulp.task('crunch', function(){
return gulp.src(paths.output)
.pipe(minify({debug: true}, function(details){
console.log(details.name + ': ' + details.stats.originalFilesize);
console.log(details.name + ': ' + details.stats.modifiedFilesize);
}))
.pipe(gulp.dest('dist'));
});
// Compile sass files
gulp.task('sassify', function(){
return gulp.src(paths.scss)
.pipe(sass());
.pipe(gulp.dest(paths.output));
});*/
// Include Gulp
/*var gulp = require('gulp')
, sass = require('gulp-sass')
, rename = require('gulp-rename');
// Define global source file path object
var paths = {
scss: 'app/scss/*.scss'
};
// Run task
gulp.task('sassify', function(err){
// Define source
return gulp.src(paths.scss)
.pipe(sass()) // Run file through sass pipe
.pipe(gulp.dest('public/css'));
});*/
// File renaming task
/*gulp.task('rename', function(){
// Define source
return gulp.src('app/css/*.css')
.pipe(rename(function(path){
path.dirname += 'app/css';
path.basename += '-minified';
path.extname = '.min.css';
}))
.pipe(gulp.dest('public'))
});
// Watcher task using browserSync to reload
/*gulp.task('watchman', ['sassify'], function(){
gulp.watch('', ['sassify']);
})
/*var gulp = require('gulp');
// include necessary plugins
var sass = require('gulp-sass')
,cleanCSS = require('gulp-clean-css')
,rename = require('gulp-rename')
,gutil = require('gulp-util')
,ftp = require('vinyl-ftp')
,browserSync = require('browser-sync').create();
// Static Server + watching scss/html files
gulp.task('serve-me', ['sass-me'], function(){
// Initialise BrowserSync
browserSync.init({
server: "./app"
});
// Set up watchers
gulp.watch('app/scss/*.scss', ['sass-me']);
gulp.watch('app/*.html').on('change', browserSync.reload);
});
// Sass-me
gulp.task('sass-me', function(){
return gulp.src('app/scss/*.scss')
.pipe(sourcemap.init())
.pipe(sass()) // Switch on sass pipe
.pipe(sourcemap.write())
.pipe(gulp.dest('app/css'));
});
// Set default gulp job (start up BrowserSync server)
gulp.task('default', ['serve']);
// Sass compile
gulp.task('sass', function(){
return gulp.src('app/scss/*.scss')
.pipe(sass()) // Switch sass plugin on
.pipe(cleanCSS({compatibility: "ie8"}))
.pipe(rename(function(path){ // Rename css file after minification
path.dirname += "";
path.basename += ".min";
path.extname = ".css"
}))
.pipe(gulp.dest('app/css')) // Set output folder
.pipe(browserSync.stream());
});
// Generic watcher job
gulp.task('watch', ['sass'], function(){
browserSync.init({
server: "./app"
});
// Watch tasks
gulp.watch('app/scss/*.scss', ['sass']);
gulp.watch('app/*.html').on('change',browserSync.reload);
});*
// CSS Minifier job
// Runs rename method after minification
gulp.task('minify-css', function(){
return gulp.src('web-build/dist/css/*.css')
.pipe(minify({compatibility: 'ie8'}, {debug: true}, function(details){
console.log(details.name + ': ' + details.stats.originalFilesize);
console.log(details.name + ': ' + details.stats.minifiedFilesize);
}))
.pipe(rename(function(path){
path.dirname += "";
path.basename += ".min";
path.extname = ".css"
}))
.pipe(gulp.dest('test'));
});
// Rename files job
gulp.task('rename', function(){
return gulp.src('web-build/dist/css/*.css')
.pipe(rename(function(path){
path.dirname += "";
path.basename += "min";
path.extname = ".css"
}))
.pipe(gulp.dest('test'));
gulp.watch('web-build/dist/css/*.css', ['rename']);
});
// Gulp FTP Deploy Job
gulp.task('deploy', function(){
// Configure ftp connection
var conn = ftp.create({
host: 'ftp181.heteml.jp',
user: 'caracri_web',
password: 'caracri6631c',
parallel: 10,
log: gutil.log
});
// Define global directory/file upload types
var globs = [
'app/src/**',
'app/css/**',
'app/js/**',
'app/fonts/**',
'app/images/**',
'app/index.html'
];
// Run Gulp job
return gulp.src(globs, { base: '.', buffer: false } )
.pipe( conn.newer( '/designsample/minamiaso/bin') ) // Only upload newer files
.pipe( conn.dest( '/designsample/minamiaso/bin' ) );
});
// Gulp FTP Delete files job
/*gulp.task('remove', function(){
// Create ftp config
var conn = ftp.create({
host: 'ftp181.heteml.jp',
user: 'caracri_web',
password: 'caracri6631c',
parallel: 10,
log: gutil.log
});
// Define Globals
var globs = [
'app/src/**',
'app/css/**',
'app/js/**',
'app/fonts/**',
'app/images/**',
'app/index.html'
];
// Set target source
return gulp.src( globs, { base: '.', buffer: false } )
.pipe( conn.rmdir( '/designsample/minamiaso/bin' ) )
.pipe( conn.dest( '/designsample/minamiaso/bin') )
}
});*/