-
Notifications
You must be signed in to change notification settings - Fork 48
/
Gruntfile.js
187 lines (158 loc) · 3.71 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
/**
* Temporary workaround for ssl issues
* https://github.com/mzabriskie/axios/issues/535#issuecomment-262299969
*/
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
module.exports = function (grunt) {
/**
*
* Function to return object from grunt task options stored as files in the 'grunt_options' folder.
*
*/
function loadConfig(path) {
var glob = require('glob');
var object = {};
var key;
glob.sync('*', { cwd: path }).forEach(function (option) {
key = option.replace(/\.js$/, '');
object[key] = require(path + option);
});
return object;
}
/**
*
* Start up config by reading from package.json.
*
*/
var dev = grunt.file.exists('local-config.json') ? grunt.file.readJSON('local-config.json') : { proxy: 'square1.tribe', certs_path: '' };
var config = {
pkg: grunt.file.readJSON('package.json'),
dev: dev,
};
/**
*
* Extend config with all the task options in /options based on the name, eg:
* watch.js => watch{}
*
*/
grunt.util._.extend(config, loadConfig('./grunt_options/'));
/**
*
* Apply config to Grunt.
*
*/
grunt.initConfig(config);
/**
*
* Usually you would have to load each task one by one.
* The load grunt tasks module installed here will read the dependencies/devDependencies/peerDependencies in your package.json
* and load grunt tasks that match the provided patterns, eg 'grunt' below.
*
*/
require('load-grunt-tasks')(grunt);
/**
*
* Tasks are registered here. Starts with default, which is run by simply running 'grunt' in your cli.
* All other use grunt + taskname.
*
*/
grunt.registerTask(
'default', [
'dist',
]);
grunt.registerTask(
'amp', [
'postcss:themeAMP',
'postcss:themeAMPMin',
'postcss:themeCartAMP',
'postcss:themeCartAMPMin',
]);
grunt.registerTask(
'wp-admin', [
'postcss:themeWPAdmin',
'postcss:themeWPAdminMin',
]);
grunt.registerTask(
'wp-gutenblocks', [
'postcss:themeGutenbergBlocks',
'postcss:themeGutenbergBlocksMin',
]);
var le = grunt.option('le') || 'mac';
grunt.registerTask(
'build', [
'clean:themeMinCSS',
'postcss:theme',
'postcss:themeMin',
'header:theme',
'postcss:themeAMP',
'postcss:themeAMPMin',
'header:themeAMP',
'postcss:themeWPAdmin',
'postcss:themeWPAdminMin',
'header:themeWPAdmin',
'postcss:themeGutenbergBlocks',
'postcss:themeGutenbergBlocksMin',
'header:themeGutenberg',
'clean:themeMinJS',
'webpack',
'concat:themeMinVendors',
'clean:themeMinVendorJS',
'lineending:' + le,
'buildTimestamp',
'setPHPConstant',
]);
grunt.registerTask(
'test', [
// 'accessibility',
'shell:test',
]);
grunt.registerTask(
'lint', [
'eslint',
'postcss:themeLint',
]);
grunt.registerTask(
'cheat', [
'shell:install',
'concurrent:dist',
'lineending:' + le,
]);
grunt.registerTask(
'dist', [
'shell:install',
'shell:test',
'concurrent:preflight',
'concurrent:dist',
'lineending:' + le,
]);
grunt.registerTask(
'dev', [
'browserSync:dev',
'watch',
]);
grunt.registerTask(
'devDocker', [
'browserSync:devDocker',
'watch',
]);
grunt.registerTask(
'icons', [
'clean:coreIconsStart',
'unzip:coreIcons',
'copy:coreIconsFonts',
'copy:coreIconsStyles',
'copy:coreIconsVariables',
'replace:coreIconsStyle',
'replace:coreIconsVariables',
'header:coreIconsStyle',
'header:coreIconsVariables',
'footer:coreIconsVariables',
'concurrent:dist',
'clean:coreIconsEnd',
'lineending:' + le,
]);
grunt.registerTask(
'buildTimestamp', 'set a PHP constant with the build timestamp', function() {
grunt.file.write( 'build-timestamp.php', "<?php\ndefine('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '');\n")
});
};