allow multiple uglify targets now: grunt [uglify:(api,et2,mail,calendar,...)]

This commit is contained in:
Ralf Becker 2016-03-01 09:57:39 +00:00
parent 4486d9d7a2
commit 337127243a
2 changed files with 24 additions and 14 deletions

View File

@ -18,6 +18,8 @@
* *
* Building happens by running in your EGroupware directory: * Building happens by running in your EGroupware directory:
* grunt * grunt
* or
* grunt uglify:<target> # targets: api, et2, mail, calendar, ...
* *
* app.js files can be added under apps target, api and et2 bundels are already there. * app.js files can be added under apps target, api and et2 bundels are already there.
* To update files in Gruntfile after adding new js files you need to run: * To update files in Gruntfile after adding new js files you need to run:
@ -34,7 +36,7 @@ module.exports = function (grunt) {
sourceMap: true, sourceMap: true,
screwIE8: true screwIE8: true
}, },
build: { api: {
files: { files: {
"phpgwapi\/js\/jsapi.min.js": [ "phpgwapi\/js\/jsapi.min.js": [
"phpgwapi\/js\/jquery\/jquery.js", "phpgwapi\/js\/jquery\/jquery.js",
@ -84,7 +86,11 @@ module.exports = function (grunt) {
"phpgwapi\/js\/jquery\/chosen\/chosen.jquery.js", "phpgwapi\/js\/jquery\/chosen\/chosen.jquery.js",
"phpgwapi\/js\/ckeditor\/ckeditor.js", "phpgwapi\/js\/ckeditor\/ckeditor.js",
"phpgwapi\/js\/ckeditor\/config.js" "phpgwapi\/js\/ckeditor\/config.js"
], ]
}
},
et2: {
files: {
"etemplate\/js\/etemplate2.min.js": [ "etemplate\/js\/etemplate2.min.js": [
"etemplate\/js\/et2_core_xml.js", "etemplate\/js\/et2_core_xml.js",
"etemplate\/js\/et2_core_common.js", "etemplate\/js\/et2_core_common.js",
@ -177,8 +183,16 @@ module.exports = function (grunt) {
"etemplate\/js\/et2_widget_script.js", "etemplate\/js\/et2_widget_script.js",
"etemplate\/js\/et2_core_legacyJSFunctions.js", "etemplate\/js\/et2_core_legacyJSFunctions.js",
"etemplate\/js\/etemplate2.js" "etemplate\/js\/etemplate2.js"
], ]
"mail\/js\/app.min.js": "mail\/js\/app.js", }
},
mail: {
files: {
"mail\/js\/app.min.js": "mail\/js\/app.js"
}
},
calendar: {
files: {
"calendar\/js\/app.min.js": "calendar\/js\/app.js" "calendar\/js\/app.min.js": "calendar\/js\/app.js"
} }
} }

View File

@ -33,12 +33,7 @@ if (!preg_match('/grunt\.initConfig\(({.+})\);/s', $content, $matches) ||
} }
//print_r($config); exit; //print_r($config); exit;
$bundle2min = array( $uglify =& $config['uglify'];
'api' => 'phpgwapi/js/jsapi.min.js',
'et2' => 'etemplate/js/etemplate2.min.js',
);
$build_files =& $config['uglify']['build']['files'];
foreach(egw_framework::get_bundles() as $name => $files) foreach(egw_framework::get_bundles() as $name => $files)
{ {
@ -51,13 +46,14 @@ foreach(egw_framework::get_bundles() as $name => $files)
}); });
//var_dump($name, $files); //var_dump($name, $files);
if (isset($bundle2min[$name])) if (isset($uglify[$name]))
{ {
$build_files[$bundle2min[$name]] = array_values($files); list($target) = each($uglify[$name]['files']);
$uglify[$name]['files'][$target] = array_values($files);
} }
elseif (isset($bundle2min[$append = substr($name, 0, -1)])) elseif (isset($uglify[$append = substr($name, 0, -1)]))
{ {
$build_files[$bundle2min[$append]] = array_merge($build_files[$bundle2min[$append]], array_values($files)); $uglify[$append]['files'][$target] = array_merge($uglify[$append]['files'][$target], array_values($files));
} }
else else
{ {