-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (68 loc) · 1.72 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
'use strict';
var path = require('path');
var gulp = require('gulp');
var gulpLoadPlugins = require('gulp-load-plugins');
var browserSyncLib = require('browser-sync');
var pjson = require('./package.json');
var minimist = require('minimist');
var glob = require('glob');
// Load all gulp plugins based on their names
// EX: gulp-copy -> copy
var plugins = gulpLoadPlugins();
// Create karma server
var KarmaServer = require('karma').Server;
var config = pjson.config;
config.defaultNotification = function(err) {
return {
subtitle: err.plugin,
message: err.message,
sound: 'Funk',
onLast: true,
};
};
var args = minimist(process.argv.slice(2));
var dirs = config.directories;
var taskTarget = args.production ? dirs.destination : dirs.temporary;
// Create a new browserSync instance
var browserSync = browserSyncLib.create();
// This will grab all js in the `gulp` directory
// in order to load all gulp tasks
glob.sync('./gulp/**/*.js').filter(function(file) {
return (/\.(js)$/i).test(file);
}).map(function(file) {
require(file)(gulp, plugins, args, config, taskTarget, browserSync);
});
// Default task
gulp.task('default', ['clean'], function() {
gulp.start('build');
});
// Build production-ready code
gulp.task('build', [
'copy',
'imagemin',
'nunjucks',
'sass',
'browserify',
'browserify-vendor',
'semantic'
]);
// Server tasks with watch
gulp.task('serve', [
'imagemin',
'copy',
'nunjucks',
'sass',
'browserify',
'browserSync',
'watch',
'browserify-vendor',
'semantic'
]);
// Testing
gulp.task('test', ['eslint'], function(done) {
new KarmaServer({
configFile: path.join(__dirname, '/karma.conf.js'),
singleRun: !args.watch,
autoWatch: args.watch
}, done).start();
});