Dotclear

source: build-tools/min-js.php @ 3801:3b615c2da0a5

Revision 3801:3b615c2da0a5, 770 bytes checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Don't keep comments inside minified JS

  • Property exe set to *
Line 
1#!/usr/bin/env php
2<?php
3/**
4 * @package Dotclear
5 * @subpackage Core
6 *
7 * @copyright Olivier Meunier & Association Dotclear
8 * @copyright GPL-2.0-only
9 */
10
11try
12{
13    $js = (!empty($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : null;
14
15    if (!$js || !is_file($js)) {
16        throw new Exception(sprintf("File %s does not exist", $js));
17    }
18
19    require dirname(__FILE__) . '/Minifier.php';
20
21    $content = file_get_contents($js);
22    $res     = \JShrink\Minifier::minify($content, array('flaggedComments' => false));
23
24    if (($fp = fopen($js, 'wb')) === false) {
25        throw new Exception(sprintf('Unable to open file %s', $js));
26    }
27    fwrite($fp, $res);
28    fclose($fp);
29} catch (Exception $e) {
30    fwrite(STDERR, $e->getMessage() . "\n");
31    exit(1);
32}
33?>
Note: See TracBrowser for help on using the repository browser.

Sites map