-
Notifications
You must be signed in to change notification settings - Fork 67
/
gruntfile.js
191 lines (171 loc) · 6.51 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
191
//@todo add a grunt log task before build : git log --pretty=format:"%h %s" --graph --since="2014-11-15"
//@todo save description in package json and copy in different place on each builds
//@todo add customizr.pot in replace version file list
module.exports = function(grunt) {
var path = require('path');
var _ = require('lodash');
var global_config = {
// path to task.js files, defaults to grunt dir
configPath: path.join(process.cwd(), 'grunt-tasks-config/'),
// auto grunt.initConfig
init: true,
// data passed into config ( => the basic grunt.initConfig(config) ). Can be used afterwards with < %= test % >
data: {
pkg: grunt.file.readJSON( 'package.json' ),
paths : {
theme_assets : 'assets/',
theme_js_assets : 'assets/front/js/',
sass_modern : 'assets/**/scss/',
front_css_modern : 'assets/front/css/',
less_classic : 'inc/assets/less/',
front_css_classic : 'inc/assets/css/',
front_js_classic : 'inc/assets/js/',
admin_css : 'assets/back/css/',
admin_js : 'assets/back/js/',
dev_php_classic : 'inc/_dev/',
inc_php_classic : 'inc/',
core_php : 'core/',
core_php_dev : 'core/_dev/',
lang : 'inc/lang/',
// New customizer
czr_assets : 'assets/czr/',
},
vars : {
textdomain : 'customizr'
},
//default less modifiers
is_rtl: 'true',
//check if a custom color is requested
skin_name : ( grunt.option.flags()[0] && -1 != grunt.option.flags()[0].indexOf('#') ) ? [ 'custom-skin-' , grunt.option.flags()[0].replace(/-|#/g, '') ].join('') : "grey",
skin_color : ( grunt.option.flags()[0] && -1 != grunt.option.flags()[0].indexOf('#') ) ? grunt.option.flags()[0].replace(/-/g, '') : "grey",
//https://www.npmjs.org/package/grunt-ssh
//Check if the context var is set and == travis => avoid travis error with ftpauth no found
//credentials : 'travis' == grunt.option('context') ? {} : grunt.file.readJSON('.ftpauth'),
customizr_tasks : {
//DEV : clean the build and watch changes (see watch task)
//'customizr4_dev': ['clean:free' , 'watch'],
'customizr_dev': ['clean:free' ,'watch'],
'common_css' : ['less:dev_common' , 'cssmin:dev_common' ],
//PROD
'prod_php' : [
'concat:init_php_classic',
'concat:front_php_classic',
'concat:admin_php',
'concat:customize_php',
//modern style
'concat:fmk_php_modern',
'concat:utils_php_modern',
'lineending:concatenated_php'
],
'prod_front_css': [
'multi:prod_skins',
'less:prod_common',
'less:prod_common_rtl',
'cssmin:prod_skins' ,
'cssmin:prod_common',
'cssmin:prod_common_rtl',
//modern style
'sass:front',
'sass:front_rtl',
'sass:front_ms_respond',
'concat:front_css_modern',
'concat:front_rtl_css_modern',
'lineending:front_css_modern',
'cssmin:prod_front_modern'
],
'prod_front_js': [
'jshint',
'concat:front_main_parts_js_classic',
'concat:front_js_classic',
'lineending:front_js',
// 'uglify:part_front_js',
// 'uglify:main_front_js',
'uglify:main_front_js_classic',
//modern style
'concat:front_main_fmk_js_modern',
'concat:front_js_modern',
'lineending:front_js_modern',
'uglify:fmk_front_js_modern',
'uglify:main_front_js_modern',
//'uglify:libs_front_js'
],
'prod_admin_css_js' : [
'cssmin:prod_admin_css',
// 'concat:czr_css',
// 'cssmin:prod_czr_css',
// 'concat:czr_control_js',
// 'concat:czr_control_js_modern',
//'comments:czr_control_js',
//'comments:czr_control_js_modern',
// 'concat:czr_preview_js',
// 'concat:czr_preview_js_modern',
'lineending:czr_js',
'uglify:prod_admin_js',
'uglify:prod_czr_js'
],
//https://www.npmjs.org/package/grunt-gitinfo
//Get Git info from a working copy and populate grunt.config with the data
'prod_build': [
//'gitinfo',
'replace',
'addtextdomain',
'makepot',
'potomo',
'clean:free',
'clean:in_customizr_pro',
'copy',
//'clean:customizr_pro_lang',
'compress'
],
//final build meta task
'customizr_build' : [
'prod_php',
'prod_front_css',
'prod_front_js',
'prod_admin_css_js',
'comments',
'prod_build'
],
//TRAVIS ci virtual machine build check on js @todo check other resources?
'travis' : ['jshint'],
//CUSTOM SKIN : call it with grunt custom_skin --#hexcolor
'custom_skin' : ['less:custom_skin' , 'cssmin:custom_skin' ],
},
uglify_requested_paths : {
src : '' || grunt.option('src'),
dest : '' || grunt.option('dest')
}
}//data
};
// LOAD GRUNT PACKAGES AND CONFIGS
// https://www.npmjs.org/package/load-grunt-config
require( 'load-grunt-config' )( grunt , global_config );
//http://www.thomasboyt.com/2013/09/01/maintainable-grunt.html
//http://gruntjs.com/api/grunt.task#grunt.task.loadtasks
//grunt.loadTasks('grunt-tasks');
// REGISTER TASKS
// grunt.util._(grunt.config('customizr_tasks')).map(function(task, name) {
// grunt.registerTask(name, task);
// });
_.map( grunt.config('customizr_tasks'), function(task, name) {
grunt.registerTask(name, task);
});
//DEV WATCH EVENT
//watch is enabled only in dev mode
grunt.event.on('watch', function(action, filepath, target) {
var files = [
{
expand: true,
cwd: '.',
src: [
filepath,
]
}
];
grunt.log.writeln( 'WATCH EVENT INFOS : ', grunt.task.current.name , action, filepath, target);
if ( 'admin_customizer_control_js' == target || 'admin_js' == target ) {
//if some js admin scripts have been changed in dev mode, jshint them dynamically
grunt.config('jshint.those', [filepath]);
}
});
};