-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
81 lines (74 loc) · 2.36 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
/**
* gulfile.js - Entry point for launching KnowTheCodeGulp
*
* @package UpGulp
* @since 1.0.2
* @author hellofromTonya
* @link https://KnowTheCode.io
* @license GPL-2.0+
*
* This gulpfile.js is a customized version of the wd_s from WebDevStudios
* @link https://github.com/WebDevStudios/wd_s/blob/master/Gulpfile.js
*/
/**********************************************
* Declarations
*********************************************/
var gulp = require( 'gulp' ),
/**
* Fetch all of the plugins out of the package.json file.
* This reduces redundancy and keeps us DRY.
*/
plugins = require( 'gulp-load-plugins' )( {
pattern: '*'
} ),
/**
* Fetch where the `config.js` is located within the theme. This value
* is stored in the `package.json` file and keyed by `gulpConfig`.
*/
gulpConfig = require( './package' ).gulpConfig,
/**
* We want to make sure we have the module's root, as files are being
* loaded and processed from subfolders.
*/
moduleRoot = require( 'app-root-path' ).resolve( './' ),
/**
* Now load the `config.js` file, which has all of the
* settings and parameters for the tasks.
*/
config = require( "./" + gulpConfig )( moduleRoot );
/**
* Load up the reload into plugins.
*/
plugins.reload = plugins.browserSync.reload;
/**********************************************
* Task Module Loader
* ********************************************
*
* Get the Task from the tasks folder. Using this architecture,
* we are able to parse out the tasks into separate files, which are
* located in the `gulp/tasks/` folder. This promotes a more
* modular gulp structure verses having everything loaded here
* in this one file.
*
* @since 1.0.0
*
* @param {string} task Name of the task to be loaded.
*
* @returns {*}
*/
function getTask( task ) {
var taskDir = config.gulpDir + 'tasks/' + task;
return require( taskDir )( gulp, plugins, config );
}
var tasks = ['i18n', 'icons', 'imagemin', 'styles', 'scripts', 'sprites', 'watch'];
for ( var index in tasks ) {
getTask( tasks[ index ] );
}
/**********************************************
* Callable Tasks
* ********************************************
*
* Here are the individual tasks which can be run. Notice that
* they load up the task file when called.
*/
gulp.task( 'default', ['sprites', 'i18n', 'icons', 'styles', 'scripts', 'imagemin' ] );