-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
117 lines (105 loc) · 3.63 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
(function() {
'use strict';
var gulp = require('gulp'),
connect = require('gulp-connect'),
open = require('gulp-open'),
rename = require('gulp-rename'),
header = require('gulp-header'),
path = require('path'),
uglify = require('gulp-uglify'),
size = require('gulp-size'),
sourcemaps = require('gulp-sourcemaps'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
sass = require('gulp-sass'),
paths = {
scripts: 'src/*.js',
styles: 'src/*.scss',
dist: 'dist/',
demo: 'demo/',
themes: 'src/themes/*.scss'
},
fk = {
pkg: require('./package.json'),
date: {
year: new Date().getFullYear(),
month: ('January February March April May June July August September October November December').split(' ')[new Date().getMonth()],
day: new Date().getDate()
},
banner: [
'/*!',
' * Burgermenu <%= pkg.version %>',
' * <%= pkg.description %>',
' * ',
' * <%= pkg.homepage %>',
' * ',
' * Copyright <%= date.year %>, <%= pkg.author.name %>. Licensed under <%= pkg.license %>.',
' * ',
' * Released on: <%= date.month %> <%= date.day %>, <%= date.year %>',
' */',
' ',''].join('\n')
};
gulp.task('scripts', function() {
gulp.src(paths.scripts)
.pipe(header(fk.banner, { pkg: fk.pkg, date: fk.date }))
.pipe(gulp.dest(paths.dist))
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('styles', function() {
gulp.src(paths.styles)
.pipe(header(fk.banner, { pkg: fk.pkg, date: fk.date }))
.pipe(sass({outputStyle: 'expanded'}))
.pipe(gulp.dest(paths.dist));
gulp.src(paths.themes)
.pipe(header(fk.banner, { pkg: fk.pkg, date: fk.date }))
.pipe(sass({outputStyle: 'expanded'}))
.pipe(gulp.dest(paths.dist + 'themes/'));
});
gulp.task('build', function () {
gulp.src(paths.scripts)
.pipe(header(fk.banner, { pkg: fk.pkg, date: fk.date }))
.pipe(size({title: 'Burgermenu scripts'}))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(sourcemaps.init())
.pipe(uglify({
preserveComments: 'some',
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true
}
}))
.pipe(size({title: 'Burgermenu minified scripts' }))
.pipe(sourcemaps.write('./maps'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.dist));
gulp.src(paths.styles)
.pipe(header(fk.banner, { pkg: fk.pkg, date: fk.date }))
.pipe(sass({outputStyle: 'compact'}))
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest(paths.dist));
});
gulp.task('watch', function () {
gulp.watch(paths.scripts, [ 'scripts' ]);
gulp.watch([paths.styles, paths.themes], [ 'styles' ]);
});
gulp.task('connect', function () {
return connect.server({
root: './',
port:'3000'
});
});
gulp.task('open', function () {
return gulp.src(paths.demo + 'demo1.html').pipe(open({ uri: 'http://localhost:3000/' + paths.demo + 'demo1.html'}));
});
gulp.task('dist', ['styles', 'scripts', 'build']);
gulp.task('server', ['watch', 'connect', 'open']);
gulp.task('default', ['server']);
})();