forked from framework7io/framework7-plugin-keypad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
118 lines (110 loc) · 4.07 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
(function(){
'use strict';
var gulp = require('gulp'),
connect = require('gulp-connect'),
open = require('gulp-open'),
less = require('gulp-less'),
rename = require('gulp-rename'),
header = require('gulp-header'),
path = require('path'),
uglify = require('gulp-uglify'),
minifyCSS = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
fs = require('fs'),
paths = {
root: './',
build: 'build/',
dist: 'dist/',
demo: 'demo/',
source: 'src/',
},
plugin = {
filename: 'framework7.keypad',
pkg: require('./bower.json'),
banner: [
'/**',
' * <%= pkg.name %> <%= pkg.version %>',
' * <%= pkg.description %>',
' * ',
' * <%= pkg.homepage %>',
' * ',
' * Copyright <%= date.year %>, <%= pkg.author %>',
' * The iDangero.us',
' * http://www.idangero.us/',
' * ',
' * Licensed under <%= pkg.license.join(" & ") %>',
' * ',
' * Released on: <%= date.month %> <%= date.day %>, <%= date.year %>',
' */',
''].join('\n'),
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()
}
};
gulp.task('scripts', function (cb) {
gulp.src(paths.source + plugin.filename + '.js')
.pipe(header(plugin.banner, { pkg : plugin.pkg, date: plugin.date } ))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(gulp.dest(paths.build))
.pipe(connect.reload());
cb();
});
gulp.task('styles', function (cb) {
gulp.src(paths.source + plugin.filename + '.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(header(plugin.banner, { pkg : plugin.pkg, date: plugin.date }))
.pipe(gulp.dest(paths.build))
.pipe(connect.reload());
cb();
});
gulp.task('build', ['scripts', 'styles'], function (cb) {
cb();
});
gulp.task('dist', function () {
gulp.src([paths.build + plugin.filename + '.js'])
.pipe(gulp.dest(paths.dist))
.pipe(uglify())
.pipe(header(plugin.banner, { pkg : plugin.pkg, date: plugin.date }))
.pipe(rename(function(path) {
path.basename = plugin.filename + '.min';
}))
.pipe(gulp.dest(paths.dist));
gulp.src(paths.build + plugin.filename + '.css')
.pipe(gulp.dest(paths.dist))
.pipe(minifyCSS({
advanced: false,
aggressiveMerging: false,
}))
.pipe(header(plugin.banner, { pkg : plugin.pkg, date: plugin.date }))
.pipe(rename(function(path) {
path.basename = plugin.filename + '.min';
}))
.pipe(gulp.dest(paths.dist));
});
gulp.task('watch', function () {
gulp.watch(paths.source + '*.js', [ 'scripts' ]);
gulp.watch(paths.source + '*.less', [ 'styles' ]);
gulp.watch(paths.demo + '*.*', function () {
gulp.src(paths.demo)
.pipe(connect.reload());
});
});
gulp.task('connect', function () {
return connect.server({
root: [ paths.root ],
livereload: true,
port:'3000'
});
});
gulp.task('open', function () {
return gulp.src(paths.demo + 'index.html').pipe(open({ uri: 'http://localhost:3000/' + paths.demo + 'index.html'}));
});
gulp.task('server', [ 'watch', 'connect', 'open' ]);
gulp.task('default', [ 'server' ]);
})();