meenie / munee

Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation
https://munee.herokuapp.com/
MIT License
833 stars 92 forks source link

can not load web font correctly that is indicated in css #79

Closed ghost closed 9 years ago

ghost commented 9 years ago
@font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 300;
    src: local('Source Sans Pro Light'), local('SourceSansPro-Light'), url('../fonts/toadOcfmlt9b38dHJxOBGOode0-EuMkY--TSyExeINg.woff2') format('woff2'), url('../fonts/toadOcfmlt9b38dHJxOBGNbE_oMaV8t2eFeISPpzbdE.woff') format('woff');
}

i can not load the font.

meenie commented 9 years ago

What's the CSS that is generated after running through Munee? Can you please post it?

meenie commented 9 years ago

@polaris-zx: Please reopen this issue if you're still having issues.

arysom commented 9 years ago

I also have an issue with @font-face

@font-face {
    font-family: 'cholaslab';
    src: url("/assets/fonts/chollaslabotce-regular.woff"), 
           url("/assets/fonts/chollaslabotce-regular.eot"),     
           url("/assets/fonts/chollaslabotce-regular.ttf") format("truetype"), 
           url("/assets/fonts/chollaslaslabotce-regular.svg") format("svg");
}

compiles to: @font-face{font-family:"cholaslab";src:url("/index.php?files=/assets/fonts/chollaslabotce-regular.woff"),url("/index.php?files=/assets/fonts/chollaslabotce-regular.eot"),url("/index.php?files=/assets/fonts/chollaslabotce-regular.ttf") format("truetype"),url("/index.php?files=/assets/fonts/chollaslaslabotce-regular.svg") format("svg");

I'm using codeigniter(mvc), so any request goes through index.php and I don't use htaccess using munee, so my link href looks like: "munee?files=/assets/css/style.css&minify=true"

Anyway, great job!

meenie commented 9 years ago

So you are using codeigniter to run the request through Munee? Meaning you are using it's Dispatcher? You are using the API directly?

meenie commented 9 years ago

Also, it shouldn't be rewriting any of your font URL's because they are already absolute (starting with a /). You can see that I have a rule for that here: https://github.com/meenie/munee/blob/master/src/Munee/Asset/Type/Css.php#L222

meenie commented 9 years ago

Actually, I see now where this might an issue and I see a fix for it :). I'm guessing the code path is going into here: https://github.com/meenie/munee/blob/master/src/Munee/Asset/Type/Css.php#L248. You should set the MUNEE_DISPATCHER_FILE constant to munee and this should fix it for you.

The thing is, it shouldn't be running font files through Munee in the first place because it won't know what to do with them. The usual rule for the .htaccess is to specify which files it should run through Munee: css|less|scss|js|coffee|jpg|png|gif|jpeg. It looks like this is a bug. It should fix the URL's if they aren't absolute, but if you are not using the URL Rewrite functionality, it should only run supported files through Munee. I'll create a ticket for that.

arysom commented 9 years ago

Im using Dipatcher inside my controller, not API. And it's working, things minify and concat.

<?php
class Munee extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        require APPPATH.'vendor/autoload.php';
        echo \Munee\Dispatcher::run(new \Munee\Request());
    }

    function index() //it has to be
    { }
}

I wanted to use Munee without htaccess to have more control, when I want to use it, so I went with no htaccess.

Changing MUNEE_DISPATCHER_FILE to munee also doesnt work for me, now things change to url("munee?files=/assets/fonts/chollaslabotce-regular.eot"),

arysom commented 9 years ago

Sending font files through munee dispatcher returns error Error: The following extension is not handled: woff , so maybe try to filter types of files inside url to ignore font extensions ?

meenie commented 9 years ago

Sending font files through munee dispatcher returns error Error: The following extension is not handled: woff , so maybe try to filter types of files inside url to ignore font extensions ?

Yup, which is why I created #88 :). Thanks for reporting this bug! Oversite on my part.