This repository was archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgulpfile.js
78 lines (67 loc) · 2.36 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
// Assigning modules to local variables
var gulp = require('gulp');
var sass = require('gulp-sass');
var clean = require('gulp-clean');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var pkg = require('./package.json');
// Set the banner content
var banner = ['/*!\n',
' * BitURL - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
' * Copyright 2016-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
' */\n',
''
].join('');
gulp.task('sass', ['clean-css'], function () {
return gulp.src('./frontend/sass/*.sass')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./app/assets/css'));
});
// Minify CSS
gulp.task('minify-css', ['sass'], function() {
return gulp.src('./app/assets/css/style.css')
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(header(banner, { pkg: pkg }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./app/assets/css'))
.pipe(browserSync.reload({
stream: true
}))
});
// Minify JS
gulp.task('minify-js', ['clean-js'], function() {
return gulp.src('./frontend/js/shorten.js')
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./app/assets/js'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('clean-js', function(){
return gulp.src(['./app/assets/js/shorten.min.js'], {read: false})
.pipe(clean());
});
gulp.task('clean-css', function(){
return gulp.src(['./app/assets/css/style.css'], {read: false})
.pipe(clean());
});
gulp.task('clean-min-css', function(){
return gulp.src(['./app/assets/css/style.min.css'], {read: false})
.pipe(clean());
});
gulp.task('build-css', ['minify-css'], function(){
return gulp.src(['./app/assets/css/style.css'], {read: false})
.pipe(clean());
});
gulp.task('build', ['build-css','minify-js']);
// Watch Task that compiles SASS and watches JS changes
gulp.task('dev', ['build-css','minify-js'], function() {
gulp.watch('./frontend/sass/*.sass', ['build-css']);
gulp.watch('./frontend/js/*.js', ['minify-js']);
});