-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
109 lines (101 loc) · 2.89 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
sourcemaps = require('gulp-sourcemaps'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
header = require('gulp-header'),
lr = require('tiny-lr'),
plumber = require('gulp-plumber'),
runSequence = require('run-sequence'),
zip = require('gulp-zip'),
server = lr();
var pkg = require('./package.json');
var banner = '/*!\n' +
' * <%= pkg.title %> - v<%= pkg.version %>\n' +
' *\n' +
' * <%= pkg.description %>\n' +
' *\n' +
' *\n' +
' * @author <%= pkg.author.name %>\n' +
' * @website <%= pkg.homepage %>\n' +
' *\n' +
' * @copyright Authentiq <%= new Date().getFullYear() %>\n' +
' * @license under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
' */\n';
gulp.task('default', function () {
gulp.start('sass', 'js');
});
gulp.task('sass', function () {
return gulp.src([
'./{admin,public}/sass/**/*.scss',
'!./node_modules{,/**}'
])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({style: 'expanded', bare: true})).on('error', gutil.log)
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(sourcemaps.write())
.pipe(rename(function (path) {
path.dirname = path.dirname.replace('sass', 'css');
}))
.pipe(gulp.dest(''))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest(''))
.pipe(livereload(server))
.pipe(notify({message: 'Styles compiled.'}));
});
gulp.task('js', function () {
return gulp.src([
'./{admin,public}/js/**/*.js',
'!./{admin,public}/js/**/*.min.js',
'!./node_modules{,/**}'
])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest(''))
.pipe(livereload(server))
.pipe(notify({message: 'Scripts compiled.'}));
});
gulp.task('build', function () {
runSequence(
['sass', 'js'],
function () {
gulp.src(
[
'admin/**',
'languages/**',
'includes/**',
'public/**',
'uninstall.php',
'authentiq.php'
],
{base: './'}
).pipe(gulp.dest('build/authentiq-wordpress/'))
.pipe(zip('authentiq-wordpress.zip'))
.pipe(gulp.dest('build/'));
}
);
});
gulp.task('watch', function () {
server.listen(35729, function (err) {
if (err) {
gutil.log(err);
}
});
gulp.watch('./{admin,public}/sass/**/*.scss', ['sass']);
gulp.watch([
'./{admin,public}/js/**/*.js',
'!./{admin,public}/js/**/*.min.js',
], ['js']);
});