catcombo / go-staticfiles

Collects assets (css, js, images...) from a different locations and tags file names with a hash for easy versioning and aggressive caching.
MIT License
14 stars 2 forks source link

Problems on Windows #2

Closed frederikhors closed 5 years ago

frederikhors commented 5 years ago

This project is wonderful and it's something I would have done - sooner or later. So thank you again.

I'm trying to use it but I have some doubts.

REPRODUCTION

You can find a reproduction of my project here: https://github.com/frederikhors/test_go_staticfiles

I'm using the amazing quicktemplate but you can try it with go templates too.

You can find a Readme.md in the project.

The branch master is without go-staticfiles, my doubts are in branch staticfiles.

You have a comparison here: https://github.com/frederikhors/test_go_staticfiles/compare/staticfiles?expand=1.

THE PROBLEM

If I follow your usage instructions I change my code from this:

<link rel="stylesheet" href="/static/css/base.css"/>

to this:

<link rel="stylesheet" href="{%s StaticFilesPrefix + Storage.Resolve("css/base.css") %}"/>

but the result is:

<link rel="stylesheet" href="/static/"/>

instead of what I expect:

<link rel="stylesheet" href="/static/css/base.934823cbc67ccf0d67aa2a2eeb798f12.css"/>

WHAT I TRIED

I understand this is a problem with the generated .json manifest you create.

I need to use this:

<link rel="stylesheet" href="{%s StaticFilesPrefix + Storage.Resolve("web\\static\\css\\base.css") %}"/>

to get something from Storage.Resolve().

I think because the content of .json manifest is:

{"paths":{"web\\static\\css\\base.css":"web\\public\\web\\static\\css\\base.934823cbc67ccf0d67aa2a2eeb798f12.css"},"version":1}

Now the final html is:

<link rel="stylesheet" href="/static/web\public\web\static\css\base.934823cbc67ccf0d67aa2a2eeb798f12.css"/>

which is wrong again because my server is serving files from web/public/web/static folder (and this is ugly itself) but on path http://localhost:3000/static without the need for useless web\public\web\static\.

ANOTHER QUESTION

And why the backslashes?


Maybe a problem or maybe it's me.

Thanks again.

catcombo commented 5 years ago

It works fine for me, but I knew what's happened. It's happened to me too when I worked on Windows - back slashes in paths. I patched the develop branch. Please check it and tell me whether the problem fixed.

frederikhors commented 5 years ago

@catcombo I'm not on Windows right now. I will try in a few days. I'll let you know.

frederikhors commented 5 years ago

I tried with v0.1.2. Everything works. Thanks.