-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getOutputPaths() as well as getPages() Event Listeners do not deliver paths for generated html files. #602
Comments
What exactly do they return for you? Please share the entire output of both of those methods if possible. Are you on Windows? |
Hey @bakerkretzmar, I am on Mac OS Catalina, Using PHP 7.3.29 (cli) (built: Aug 15 2021 23:10:16) ( NTS ) here is the output of my build folder: sample code 1: $events->afterBuild(function ($jigsaw) {
$paths = $jigsaw->getOutputPaths();
$paths->each(function ($item) use ($jigsaw) {
error_log($item . "\n", 3, "/Users/Nico/Documents/Code/log/php-error.log");
});
}); output 1 (include white space):
sample code 2: $events->afterBuild(function ($jigsaw) {
$paths = $jigsaw->getPages();
$paths->each(function ( $item, $key) use ($jigsaw) {
error_log($key . "\n", 3, "/Users/Nico/Documents/Code/log/php-error.log");
});
});
output 2 (include white space):
as you can see, index.html is missing in both cases. |
Gotcha, thanks. For now you should be able to safely assume that there will always be exactly one item in the output paths array that is an empty string, and that path is actually To get a better look at what's in those collections, you can $events->afterBuild(fn ($jigsaw) => dump($jigsaw->getOutputPaths()));
$events->afterBuild(fn ($jigsaw) => dump($jigsaw->getPages())); |
Okay, I will investigate and see if I can work around this bug and implement my Minifier in a more convenient way :)
doc states: "getPages() (afterBuild only) Returns a collection of all output files that were generated. " So..I guess...Not intentional? :) Thanks a lot! |
one more thing, dump() does not output logs to the build outout for me, but maybe I am mistaken where to look - can you please point me into the right direction on where to find the results of dump(), please? |
using something along the lines of this now and hope it does not break :) $build_files = $jigsaw->getOutputPaths();
$build_files->each(function ($item) use ($jigsaw) {
if (gettype($item) == "string") {
if (strlen($item) == 0) {
$item = "/index.html";
}
if (str_contains($item, ".html")) {
minify($item, $jigsaw);
}
}
}); |
It should just show up in your terminal, wherever you're running the build. |
It looks like there's other output missing there... does that build succeed? On a fresh install it should show the two lines you have there, then the dumps, then |
Hope this helps: Scenario 1:bootstrap.php <?php
use TightenCo\Jigsaw\Jigsaw;
/** @var $container \Illuminate\Container\Container */
/** @var $events \TightenCo\Jigsaw\Events\EventBus */
$events->afterBuild(fn ($jigsaw) => dump($jigsaw->getOutputPaths()));
Results: build: builds normally, all files are built and copied as expected, with the following output: serve: does not start server. Hangs. Scenario 2:bootstrap.php <?php
use TightenCo\Jigsaw\Jigsaw;
/** @var $container \Illuminate\Container\Container */
/** @var $events \TightenCo\Jigsaw\Events\EventBus */
Results: build: builds normally, all files are built and copied as expected, with the following output: |
Weird... are you calling |
nope, fresh install. If you want, we can set up a quick call next week and you can investigate my setup remotely :) If there is any other branch or thing I can test, please let me know. |
As the title says.
if I start with an empty jigsaw project (no template), normally one index.html file is generated on build. Using said
getOutputPaths()
orgetPages()
Event Lsitener in boostrap.php does not deliver a collection entry for the generated index.html file, instead, the first array entry is empty, followed by the paths for the flatfiles (like png, css, js and so on).I found this behaviour when I tried to use this function for implementing an HTML minifier for jigsaw: #116 (comment)
If you need fruther info, please let me know. Installed jigsaw yesterday, so I think it's a pretty recent version.
oh, and if you have built-in nice error logging function, pleeeeeeeease let me know, for now I am using error_log on build and it feels so so so wrong. Documentation about deugging and logging would be really helpful :)
The text was updated successfully, but these errors were encountered: