fitztrev / laravel-html-minify

Minifies the HTML output of Laravel 4 applications
https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying
MIT License
415 stars 76 forks source link

Issue with gulpfile #56

Open coffebar opened 9 years ago

coffebar commented 9 years ago

I'm trying to use this https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying

but something wrong

[00:08:35] Starting 'compress'...

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Parse Error: <link rel="stylesheet" href="<?php echo e(elixir("css/all.css")); ?>">

file: somethng like this

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php echo $title; ?></title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
    <link rel="stylesheet" href="<?php echo e(elixir("css/all.css")); ?>">
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <link rel="icon" href="<?php echo e(asset("/images/my.ico")); ?>" type="image/x-icon" />
    <?php echo $__env->yieldContent('head'); ?>

</head>
<body> ...</body>
</html>
MathieuUrstein commented 9 years ago

I'm having the same issue

rappasoft commented 9 years ago

As am I

peshkov3 commented 9 years ago

And it's still an error

pbean commented 9 years ago

same here

will666 commented 8 years ago

Indeed same here

tibm commented 8 years ago

same here

rappasoft commented 8 years ago

+1

mp31415 commented 8 years ago

+1

AriaEdo commented 8 years ago

+1

timvanuum commented 8 years ago

+1

bruno-farias commented 8 years ago

+1

jAddict7 commented 8 years ago

+1 ... Anyone got solution?

peshkov3 commented 8 years ago

@jAddict7, I use middleware, which contain following handle method:

public function handle($request, Closure $next)
{
        $response = $next($request);
        if ($response instanceof \Illuminate\Http\Response) {
            $output = $response->getContent();
            $output = preg_replace('/<!--([^\[|(<!)].*)/', '', $output);
            $output = preg_replace('/(?<!\S)\/\/\s*[^\r\n]*/', '', $output);

            // Clean Whitespace
            // I've commented this line because it was cuting some html
         // $output = preg_replace('/\s{2,}/', '', $output);
            $output = preg_replace('/(\r?\n)/', '', $output);
            $response->setContent($output);
        }

       return $response;
}

You can find this solution in the web

jAddict7 commented 8 years ago

@peshkov3 Thank you .. I will give a try ...

cardei commented 8 years ago

Anyone got a solution for this issue?