Giter VIP home page Giter VIP logo

Comments (11)

bhauman avatar bhauman commented on May 17, 2024

For figwheel to work you have to have your css below the web root directory. Look at the example project. This defaults to resources public.

The url you should be seeing is "//localhost:3449/css/app.css?rel=1414087417074".

If you are using the default setup you just need to move your css folder into the resources/public directory.

If that's not going to help you can you send me your cljsbuild and figwheel config info from your project.clj?

from lein-figwheel.

iand675 avatar iand675 commented on May 17, 2024

Thanks for clarifying that! With a little bit of work I've got the CSS I want reloading into resources/public, but now I'm hitting a new issue. It looks like figwheel doesn't have CORS headers set for fonts:

Font from origin 'http://localhost:3449' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://circlehost:8080' is therefore not allowed access. 

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

I find it strange that you are having this problem. Where is the font request being generated from? If it's being generated from CSS what is the origin of the CSS file?

A general solution for your problem in the near term is to use the :url-rewriter client configure option. Supply :url-rewriter with a function that takes a URL and returns a URL that points to the asset in your app server.

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

Sorry your having these troubles I look into having a open CORS configuration. I didn't think Figwheel needed it.

from lein-figwheel.

iand675 avatar iand675 commented on May 17, 2024

No worries! I'm a little surprised too, but certainly appreciate the help.

Here's an example of the CSS that's triggering this:

@font-face {
  font-family: ProximaNova;
  src:url('../../webfonts/ProximaNova300.eot');
}

Where the CSS is in /public/css/app.css

from lein-figwheel.

Deraen avatar Deraen commented on May 17, 2024

I have the same issue (with the fonts) when I'm loading the page from my own ring server and thus the CSS is loaded from e.g. localhost:8080 when loading the page the first time. When figwheel reloads the CSS it's loaded from port 3449 and browser refuses to load the fonts.

Looks like I can use :url-writer to fix this but it would be nice if it worked by default.
Would it make sense if files were reloaded from the current host instead of figwheel server?

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

I here you here. I'm currently suffering from adding CSS reloading as a convenient afterthought.

Reloading from the Figwheel server makes sense because I know for sure what that path is and for other several other reasons. The path to assets on a custom server can be arbitrary and would require configuration to know it.

Fetching from the figwheel server allows it "to just work" in a great many cases.

I thought that script and link tags wouldn't trigger CORS problems but I didn't think it through fully. I'm going to add the CORS headers and hopefully that will fix it.

I'm not planning on focusing on CSS reloading as it gets really complex and there are many solutions out there already.

Sound fair?

On Nov 1, 2014, at 4:28 AM, Juho Teperi [email protected] wrote:

I have the same issue (with the fonts) when I'm loading the page from my own ring server and thus the CSS is loaded from e.g. localhost:8080 when loading the page the first time. When figwheel reloads the CSS it's loaded from port 3449 and browser refuses to load the fonts.

Looks like I can use :url-writer to fix this but it would be nice if it worked by default.
Would it make sense if files were reloaded from the current host instead of figwheel server?


Reply to this email directly or view it on GitHub.

from lein-figwheel.

Deraen avatar Deraen commented on May 17, 2024

Sounds fair.

This is what I used to get my project working:

  :url-rewriter (fn [u] (clojure.string/replace u ":3449" ":3000"))

Maybe there should be a note about :url-rewriter somewhere in the docs?

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

There should absolutely be a note about :url-rewriter in the docs. Working on it.

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

Just added cors headers and confirmed that it fixes the font-face problem in Chrome.
I'll hopefully have a release today.

from lein-figwheel.

bhauman avatar bhauman commented on May 17, 2024

Added the :url-rewriter docs

from lein-figwheel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.