Code Monkey home page Code Monkey logo

Comments (7)

niftylettuce avatar niftylettuce commented on August 29, 2024

@Nevtep what does your view look like for this? (e.g. how are you using != CDN()?)

from express-cdn.

Nevtep avatar Nevtep commented on August 29, 2024

Yes, I have my code like this:

!= CDN('/stylesheets/app/button.css')

Should I reference .styl instead?

from express-cdn.

niftylettuce avatar niftylettuce commented on August 29, 2024

@Nevtep so for CSS files, express-cdn basically does a GET request to that URL and returns the body of the response. I recently patched this module, so you could first try removing and then installing the latest version 0.1.0. The problem likely lies with how your stylus middleware works. If the .css file is not actually created locally in your filesystem when a request is sent to that URL, then when we try to upload it to S3, it will give you the error you're receiving. Here is where the GET request is https://github.com/niftylettuce/express-cdn/blob/master/lib/main.js#L329. Also note that the file must actually get saved to the filesystem, due to fs.statSync being used to get the mtime.getTime() which is used for appending a timestamp for cachebusting to the file (e.g. button.123456789.css). I would recommend to check that the file is actually created at that path when the CSS file gets requested, example given below:

curl http://yourApp:3000/public/stylesheets/app/button.css

from express-cdn.

Nevtep avatar Nevtep commented on August 29, 2024

Nick, thanks for the quick response, actually the problem is just as you described, I'm .gitignoring *.css files since they get generated when the url is called, but they are not there the first time I call the url (eg, after a deploy) is there a workaround for this? since I would need to generate all css files locally before deploying each time to get them updated and get the correct timestamp, and start including them on the repo and deploys and would prefer not to do that.

from express-cdn.

niftylettuce avatar niftylettuce commented on August 29, 2024

Yeah, this is the same problem I have with my LESS assets (previously used Stylus). I just deploy the CSS to production after I test it locally.

from express-cdn.

Nevtep avatar Nevtep commented on August 29, 2024

Ok, will do... just a thought I had, would be cool to be able to reference stylus files (or less, or whatever is supported) and get the css file refence... the timestamp of the files wouldn't change, and you still get the content through a GET request so no need to include .css anymore =)

Thanks Nick, this library has given me great CDN integration and was simple to integrate it into my solution.

I'm closing this one.

from express-cdn.

niftylettuce avatar niftylettuce commented on August 29, 2024

You're very welcome, I'm glad it worked out for you too. I really appreciate this module's simplicity despite it being a bit "hacky". I've been able to deploy it to https://getprove.com in 5 minutes flat, and the optimization/performance it brings is staggering. The module overall needs a clean rewrite, maybe a few CDN sponsors, and then it'd be top notch where we need it :) Cheers and feel free to share your implementation to [email protected]

from express-cdn.

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.