I want to use a separate domain as a JavaScript framework and it will create a base require config which I can augment from the app.
foo.example.com
main.js
lib/foo-specific.js
framework.example.com
framework.js <-- entry point
lib/jquery.js
lib/etc...
Optimally, I'd like to be able to require 'lib/foo-specific' and/or 'lib/jquery' and have the paths just resolve nicely, but from what I've found, there's no way to do this, unless I use a specific path key/value for every js file in the framework. At the moment, I've got a custom plugin to load the given path with a different base url (e.g. fw!lib/jquery
), though if I wanted to use the text!
plugin, it won't work as plugin chaining is unsupported.
See https://github.com/jpillora/js-framework for what I've currently got, and also https://github.com/jpillora/prettyprinter for a use case.
Is there a clean way to solve this ? or to achieve multiple base URLs ?
Note: I have also looked into multiple require instances, though I don't think that would work as I'd like the the app to be able to access the framework's config.
See Question&Answers more detail:os