|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Build script that compiles dist/go.php into a fully self-contained file |
| 3 | + * Build script that compiles build/go.php into a fully self-contained file |
4 | 4 | * with CSS, JS, and the shared text parser baked in. |
5 | | - * Output goes to dist/go-standalone.php. |
6 | 5 | * |
7 | | - * Run: php build-go.php |
| 6 | + * Run: php build/build.php |
8 | 7 | */ |
9 | 8 |
|
10 | | -$source = file_get_contents(__DIR__ . '/dist/go.php'); |
11 | | -$css = file_get_contents(__DIR__ . '/dist/styles.css'); |
12 | | -$js = file_get_contents(__DIR__ . '/dist/app.js'); |
| 9 | +$root = dirname(__DIR__); |
| 10 | + |
| 11 | +$source = file_get_contents(__DIR__ . '/go.php'); |
| 12 | +$css = file_get_contents($root . '/dist/styles.css'); |
| 13 | +$js = file_get_contents($root . '/dist/app.js'); |
13 | 14 |
|
14 | 15 | // Read the shared parser, stripping its opening <?php tag |
15 | | -$parser = file_get_contents(__DIR__ . '/src/Parsers/parse_text.php'); |
| 16 | +$parser = file_get_contents($root . '/src/Parsers/parse_text.php'); |
16 | 17 | $parser = preg_replace('/^<\?php\s*/s', '', $parser); |
17 | 18 |
|
18 | 19 | // Replace the include() calls with the actual file contents |
|
23 | 24 | ); |
24 | 25 |
|
25 | 26 | $source = str_replace( |
26 | | - '<?php include(__DIR__ . "/styles.css"); ?>', |
| 27 | + '<?php include(__DIR__ . "/../dist/styles.css"); ?>', |
27 | 28 | $css, |
28 | 29 | $source |
29 | 30 | ); |
30 | 31 |
|
31 | 32 | $source = str_replace( |
32 | | - '<?php include(__DIR__ . "/app.js"); ?>', |
| 33 | + '<?php include(__DIR__ . "/../dist/app.js"); ?>', |
33 | 34 | $js, |
34 | 35 | $source |
35 | 36 | ); |
36 | 37 |
|
37 | | -file_put_contents(__DIR__ . '/dist/go-standalone.php', $source); |
| 38 | +$out = $root . '/dist/go-standalone.php'; |
| 39 | +file_put_contents($out, $source); |
38 | 40 |
|
39 | 41 | echo "Built dist/go-standalone.php (" . number_format(strlen($source)) . " bytes)\n"; |
0 commit comments