forked from argoproject/Argo
-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathGruntfile.js
190 lines (174 loc) · 4.07 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
module.exports = function(grunt) {
'use strict';
// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);
// Force use of Unix newlines
grunt.util.linefeed = '\n';
// Find what the current theme's directory is, relative to the WordPress root
var path = process.cwd().replace(/^[\s\S]+\/wp-content/, "\/wp-content");
var cssLessFiles = {
'css/gutenberg.css': 'less/gutenberg.less',
'css/style.css': 'less/style.less',
'css/editor-style.css': 'less/editor-style.less',
'homepages/assets/css/single.css': 'homepages/assets/less/single.less',
'homepages/assets/css/top-stories.css': 'homepages/assets/less/top-stories.less',
'homepages/assets/css/legacy-three-column.css': 'homepages/assets/less/legacy-three-column.less'
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
compile: {
options: {
paths: ['less'],
sourceMap: true,
outputSourceFiles: true,
sourceMapBasePath: path,
},
files: cssLessFiles
}
},
uglify: {
target: {
options: {
report: 'gzip'
},
files: [{
expand: true,
cwd: 'js',
src: [
'custom-less-variables.js',
'custom-sidebar.js',
'custom-term-icons.js',
'featured-media.js',
'floating-social-buttons.js',
'image-widget.js',
'largoCore.js',
'load-more-posts.js',
'navigation.js',
'top-terms.js',
'update-page.js',
'widgets-php.js',
'!*.min.js'
],
dest: 'js',
ext: '.min.js'
}]
}
},
cssmin: {
target: {
options: {
report: 'gzip'
},
files: [
{
expand: true,
cwd: 'css',
src: ['*.css', '!*.min.css'],
dest: 'css',
ext: '.min.css'
},
{
expand: true,
cwd: 'homepages/assets/css',
src: ['*.css', '!*.min.css'],
dest: 'homepages/assets/css',
ext: '.min.css'
}
]
}
},
shell: {
apidocs: {
command: [
'cd docs',
'rm -Rf api _build/html/api _build/doctrees/api',
'make php',
].join('&&'),
options: {
stdout: true
}
},
sphinx: {
command: [
'cd docs',
'make html',
].join('&&'),
options: {
stdout: true
}
},
msgmerge: {
command: [
'msgmerge -o lang/es_ES.po.merged lang/es_ES.po lang/largo.pot',
'mv lang/es_ES.po.merged lang/es_ES.po'
].join('&&')
},
pot: {
command: [
'wp i18n make-pot . lang/largo.pot'
].join('&&'),
options: {
stdout: true
}
},
},
watch: {
less: {
files: [
'less/**/*.less',
'less/**/**/*.less',
'homepages/assets/less/**/*.less'
],
tasks: [
'less:compile',
'cssmin'
]
},
uglify: {
files: [
'js/*.js',
'!js/*.min.js'
],
tasks: ['uglify']
},
sphinx: {
files: [
'docs/*.rst',
'docs/*/*.rst'
],
tasks: ['docs']
}
},
po2mo: {
files: {
src: 'lang/*.po',
expand: true
}
}
});
// Build API docs only
grunt.registerTask('apidocs', ['shell:apidocs']);
// Build ALL docs
grunt.registerTask('docs', ['shell:sphinx']);
// Former grunt-pot
grunt.registerTask('pot', ['shell:pot']);
// Build docs and language files
grunt.registerTask('build', 'Build assets, docs and language files', [
'less',
'cssmin',
'uglify',
'apidocs',
'docs',
'pot',
'shell:msgmerge'
]);
// Build asset files
grunt.registerTask('UI', 'Build less files and minify js', [
'less',
'cssmin',
'uglify',
]);
}