Given a project with the files below and a directory structure as follows:
$ tree --charset ascii
.
|-- index.html
|-- js
| |-- components
| | `-- vendor
| | |-- jquery-1.7.2.js
| | |-- jquery.js
| | `-- test.js
| |-- order.js
| `-- require.js
`-- nested
`-- path
`-- index.html -> ../../index.html
5 directories, 7 files
Note that the file names are below, but the directory structure is not preserved
since github gist's don't allow subduers. The directory is served statically
(using something like python -m SimpleHTTPServer
), with the require.js
config
set with baseUrl: '/js'
and the following URLs are visited:
http://127.0.0.1:8000/
http://127.0.0.1:8000/nested/path/
Here the page load works, but there are two gotchas:
it's all starting to come together...
so as long as a module calls
define()
it can use paths relative to its id, which in typical cases is the same as its path on the server.the gotcha's are:
define()
, even though it typically won't berequire
'd by anythingrequire()
call, if it is included as a<script>
tag,require.js
throws an error:require()
call that includes your entry point must be a relative path that's relative to thebaseUrl
parameter. if it's absolute the "./" paths in the entry point will be from the server root as well.the updates to the gist allow this to work wether the entry point is at the
baseUrl
or not, and whether the page is at the server root or not.so i stand corrected, @justinbmeyer! guess i won't need this path plugin...