forked from javallone/regexper-static
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
104 lines (83 loc) · 2.68 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
var gulp = require('gulp'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
config = require('./config');
function errorHandler() {
return plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
});
}
gulp.task('default', ['server'], function() {
gulp.watch(config.globs.other, ['static']);
gulp.watch([config.globs.html, config.templateFile, config.globs.sass], ['markup']);
gulp.watch(config.globs.js, ['browserify']);
});
gulp.task('server', ['build'], function() {
var connect = require('gulp-connect'),
watch = require('gulp-watch');
watch(config.buildPath('**/*'), { name: 'Server' })
.pipe(connect.reload());
return connect.server({
root: config.buildRoot,
livereload: true
});
});
gulp.task('build', ['static', 'markup', 'compass', 'browserify']);
gulp.task('static', function() {
return gulp.src(config.globs.other, { base: './src' })
.pipe(errorHandler())
.pipe(gulp.dest(config.buildRoot));
});
gulp.task('markup', ['compass'], function() {
var wrap = require('gulp-wrap'),
path = require('path'),
fs = require('fs');
return gulp.src(config.globs.html, { base: './src' })
.pipe(errorHandler())
.pipe(wrap({ src: config.templateFile }, {
date: new Date().toISOString(),
title: function() {
var root = path.join(this.file.cwd, this.file.base),
file = path.relative(root, this.file.history[0]);
return config.titles[file] || config.titles['_'];
},
svgStyles: fs.readFileSync(path.join(config.compass.css, 'svg.css'), {
encoding: 'utf-8'
})
}))
.pipe(gulp.dest(config.buildRoot));
});
gulp.task('compass', function() {
var compass = require('gulp-compass');
return gulp.src(config.globs.sass)
.pipe(errorHandler())
.pipe(compass(config.compass));
});
gulp.task('browserify', function() {
var browserify = require('browserify'),
tap = require('gulp-tap');
return gulp.src('./src/js/main.js', { read: false })
.pipe(errorHandler())
.pipe(tap(function(file) {
var bundler = browserify(config.browserify);
config.browserify.prebundle(bundler);
bundler.add(file.path);
file.contents = bundler.bundle();
}))
.pipe(gulp.dest(config.buildPath('js')));
});
gulp.task('karma', function(done) {
var karma = require('karma'),
path = require('path');
karma.server.start({
configFile: path.join(__dirname, 'karma.conf.js')
}, done);
});
gulp.task('karma:single', function(done) {
var karma = require('karma'),
path = require('path');
karma.server.start({
configFile: path.join(__dirname, 'karma.conf.js'),
singleRun: true
}, done);
});