Closed lagoasoft-lucasschmidt closed 11 years ago
@lucastschmidt,
Thanks for sharing your thoughts!
As far as prodModeOnlyRemoteFiles
goes, I think you can already accomplish what you are trying to do by using remoteFiles
, devModeOnlyFiles
, and prodModeOnlyFiles
. I updated example 5 on the dev branch to do it for JQuery. It's bundle.json
looks like:
{
"remoteFiles" : [ "http://code.jquery.com/jquery-1.10.1.min.js" ],
"devModeOnlyFiles" : "jquery-1.10.1.js",
"prodModeOnlyFiles" : "http://code.jquery.com/jquery-1.10.1.min.js"
}
In dev
mode, the local JQuery file will be used and in prod
mode, the remote CDN file will be used.
As for multiple servers storing remote files, could you elaborate on the usecase and your setup a bit more? For example, what determines what server JQuery should be loaded from?
Well, if the infrastructure has multiple servers, for testing, development, staging, production and you are storing these remoteFiles there.
staging.domain.com testing.domain.com www.domain.com
where
/static-files - you have the jquery files or other files /myapp - is my node application
Considering that and, based on the application environment configuration, I have to obtain the file from the correct server.
One way to do this, since, in my use case, all files are stored within my domain in another application, I can simply say "remoteFiles" :[ "/static-files/js/jquery.js"]. It will be correctly loaded by the browser.
Problem is that, as you know, the "remoteFiles" depends on that https protocol to be identified. Otherwise, we simply dont know if its really a remote file or not.
Thanks for the reply @go-oleg
Hey @go-oleg , I did an implementation that solve my problems, but the way I implemented, it just doesnt look too safe :smile:
Not a lot of code was changed, but its one of those things that if someone tries to understand whats going on, its impossible, its all based on trial and error. The best thing would be a complete re-write of a lot of things (architecture). If anyone needs this support, I did here: https://github.com/lucastschmidt/cartero/tree/cdn_plus_support
Basically, now, a remoteFile can be an object or a string. In case of an object, you can have the following attributes: path, devMode, prodMode, ext. The last one, I just added to properly fix that crazy case where a remote file doesnt have a recognizable extension.
I would say it doesnt make any sense to merge this into the library, but, it would be good one day, for a change of architecture/re-write, so that more features can be added (options) without possibly breaking anything.
@lucastschmidt,
Cool! Thanks for sharing it!
Hey guys, this is what I want to accomplish:
I didnt look into how to do the prodModeOnlyRemoteFiles, but it should be easy. But to accomplish the second improvement, I think it may require some more work. I havent analyzed this yet, so I may be wrong.
I just wanted to see if you guys have any ideas regarding this. Thanks.