-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
executable file
·149 lines (134 loc) · 4.13 KB
/
Gruntfile.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// *************************************
//
// Gruntfile
// -> Grunt's main configuration
//
// *************************************
module.exports = function (grunt) {
// -------------------------------------
// Load all grunt tasks from util/grunt
// -------------------------------------
require('load-grunt-config')(grunt, {
configPath: process.cwd() + '/util/grunt'
});
// -------------------------------------
// Register the grunt tasks
// -------------------------------------
// ----- Grunt init ----- //
grunt.registerTask('init', 'Initialize the development environment, build and deploy initial themes.', [
// Show warnings
//'attention:ftppass_reminder',
'attention:deletion_warning',
// Ask for necessary variables and process them
'prompt:init',
'clean:init',
'copy:init',
'mkdir:init',
'json-replace:init_npm',
'json-replace:init_bower',
'replace',
'exec:git_set_remote',
'exec:git_log_remote',
// Install and process bower libs
'exec:bower_install',
'copy:bower_libs',
// Build themes and deploy them
'build:parent',
'ftpush:deploy_parent',
'build:child:expanded',
'ftpush:deploy_child'
]);
// ----- Grunt reinit ----- //
grunt.registerTask('reinit', 'Re-initialize the development environment, build and deploy child theme.', [
// Show warnings
//'attention:ftppass_reminder', // not needed when not using FTP
// Ask for necessary variables and process them
'mkdir:init',
//'exec:git_reset_remote',
//'exec:git_log_remote',
// Install and process bower libs
'exec:bower_install',
'copy:bower_libs',
// Build child theme
'build:child:expanded',
'ftpush:deploy_child'
]);
// ----- Grunt develop ----- //
grunt.registerTask('develop', 'Build child theme, watch for changes and process them.', [
'build:child:expanded',
'watch'
]);
// ----- Grunt deploy ----- //
grunt.registerTask('deploy', 'Deploy compressed child theme to live server.', [
'clean:child',
'build:child:compressed',
'ftpush:deploy_child'
]);
// ----- Grunt build ----- //
grunt.registerTask('build', 'Build child or parent files.', function(type, style) {
if (type == null) {
grunt.warn('Build type must be specified, either build:child or build:parent.');
};
if (type === 'child' && style == null) {
grunt.warn('Child build style must be specified, either build:child:compressed or build:child:expanded.');
};
if (type === 'child') {
if (style === 'compressed') {
grunt.task.run(
// Compile sass and prefix and lint css
'sass:compressed',
'autoprefixer:compressed',
//'csslint:compressed',
// Beautify, lint, concat and minify js
'jsbeautifier:js',
// 'jshint:strict',
'concat:all',
'uglify:all',
// Process php
'copy:php_child',
'delete_sync:php_templates',
'delete_sync:php_includes',
'processhtml:compressed',
// Copy Wp child css
'copy:css_child',
// Process images
'delete_sync:img'
// Process svg icons
// 'svgstore:all'
);
};
if (style === 'expanded') {
grunt.task.run(
// Compile sass and prefix and lint css
'sass:expanded',
'autoprefixer:expanded',
// 'csslint:expanded',
// Make sure all bower libs are present
'newer:copy:bower_libs',
// Beautify, lint and copy js
'jsbeautifier:js',
// 'jshint:strict',
'newer:copy:js',
// Process php
'newer:copy:php_child',
'delete_sync:php_templates',
'delete_sync:php_includes',
'processhtml:expanded',
// Copy Wp child css
'copy:css_child',
'delete_sync:img'
// Process svg icons
// 'svgstore:all'
);
};
};
if (type === 'parent') {
grunt.task.run(
// Copy parent php
'copy:php_parent',
// Copy parent style.css
'copy:css_parent'
);
};
});
};