-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (80 loc) · 2.7 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
/**
* Dependencies
*/
'use strict';
// Configs
const configs = require('./tasks/_configs');
// Gulp + plugins
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
require('gulp-grunt')(gulp);
// Non-gulp modules
plugins.path = require('path');
plugins.browserSync = require('browser-sync');
plugins.runSequence = require('run-sequence'); //temporary solution until the release of gulp 4.0
plugins.eventStream = require('event-stream');
// Shared paths
const paths = {
// Build paths
base: __dirname,
src: plugins.path.join(__dirname, configs.paths.src),
dev: plugins.path.join(__dirname, configs.paths.dev),
dist: plugins.path.join(__dirname, configs.paths.dist),
tasks: plugins.path.join(__dirname, configs.paths.tasks),
// Assets
assets: {
styles: plugins.path.join(__dirname, configs.paths.src, 'sass'),
js: plugins.path.join(__dirname, configs.paths.src, 'js'),
fonts: plugins.path.join(__dirname, configs.paths.src, 'fonts'),
images: plugins.path.join(__dirname, configs.paths.src, 'img')
},
// HTML templates, node modules
html: plugins.path.join(__dirname, configs.paths.src, 'templates'),
modules: plugins.path.join(__dirname, 'node_modules')
};
/**
* Child tasks
*/
plugins.getTaskModule = function(task) {
return require(plugins.path.join(paths.tasks, task))(paths, gulp, plugins);
};
gulp.task('styles', plugins.getTaskModule('styles'));
gulp.task('watch', plugins.getTaskModule('watch'));
//gulp.task('bundle-libs', plugins.getModule('javascript/bundle-libs'));
//gulp.task('bundle-modules', plugins.getModule('javascript/bundle-modules'));
//gulp.task('html', plugins.getTaskModule('html-assemble'));
//gulp.task('image-fallbacks', plugins.getModule('images/fallbacks'));
//gulp.task('image-optimise', plugins.getModule('images/optimise'));
gulp.task('browser-sync', plugins.getTaskModule('browser-sync'));
/**
* Utility tasks
*/
// Clean build directory
gulp.task('clean', function(fn) {
return require('del')([
plugins.path.join(paths.dev, '*'),
plugins.path.join(paths.dist, '*')
], fn);
});
//Task to change to development phase
gulp.task('set-development', function() {
configs.production = true;
});
/**
* Main tasks
*/
//Task default
gulp.task('default', function(fn) {
plugins.runSequence('dev', fn);
});
gulp.task('build', ['clean'], function(fn) {
plugins.runSequence('styles',['grunt-assemble'], fn);
});
//Task used in development phase.
gulp.task('dev', function(fn) {
plugins.runSequence('build', ['watch', 'browser-sync'], fn);
});
//Task used for distribution
gulp.task('dist', ['set-development'], function(fn) {
plugins.runSequence('build', fn);
});