Don’t know anything about an "out of the box" solution.
But... I’ve done this myself like that:
- Chunk-Category for the JSs to include
- Document that has is set to plain text an content type javascript (for me called [tt]combined.js[/tt]) with the following call inside:
[[chunkListParser?chunks=`[[getChunks? &category=`js` ]]` &minify=`true` ]]
- Snippet [tt]chunkListParser[/tt] patched as follows:
<?php
$minify = ( isset($minify) && $minify == 'true' ) ? true : false;
$ar_chunks = split(',',$chunks);
$ar_chunks = array_unique($ar_chunks);
$output = '';
foreach ($ar_chunks as $chunk) {
if ($chunk != '') {
$c = $modx->getChunk($chunk);
if ($c) $output .= $c . "\r\n";
}
}
if ($output != '' && isset($wrapperdiv)) {
$output = '<div id="'.$wrapperdiv.'">'.$output.'</div>';
}
if ($minify == true) {
require 'assets/snippets/jsmin/jsmin-1.1.1.php';
$output = JSMin::minify($output);
}
return $output;
?>
Original was taken from here
http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
- Snippet [tt]getChunks[/tt] patched as follows:
<?php
$q_chunks = $modx->db->query('
SELECT
chunk.*
FROM '.$modx->getFullTableName('site_htmlsnippets').' AS chunk
INNER JOIN '.$modx->getFullTableName('categories').' AS category
ON chunk.category = category.id
WHERE
category.category IN ("'.$category.'")
ORDER BY
name
');
$ar_chunks = array();
while ($row = $modx->db->getRow($q_chunks)) {
$ar_chunks[] = $row['name'];
}
$l_chunks = implode(",",$ar_chunks); //splitter character changed from "||" to "," by jusi
return $l_chunks;
?>
- jsmin from here
http://code.google.com/p/jsmin-php/
EDIT: path to jsmin is in [tt]chunkListParser[/tt] Snippet.
EDIT2: re-reading your post, you’re talking about files... My solution takes the JSs from the DB.
Hope this helps...
Greetz
JUSI