Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

`baseUrl` not properly set or configured in generated requirejs files? #62

Open
jergason opened this Issue · 3 comments

4 participants

Jamison Dance Robert Mazan Martin Etmajer zzswang
Jamison Dance

I am working on a node app with a directory structure like so:

├── app.js
├── package.json
├── public
│   ├── admin.html
│   ├── jam
│   ├── js

My app is serving up the public directory directly, so if you request http://example.com/admin.html it will give you public/admin.html.

I am running in to problems making jam create the correct paths in the generate requirejs files. The relevant portions of my package.json file looks like this:

  "jam": {
    "packageDir": "public/jam",
    "baseUrl": "public",
    "dependencies": {
      "angularjs": "1.0.1"
    }
  },

So I specify to install into the public directory, and to use that as a baseUrl. I expect the baseUrl in the generated require.js and require.config.js files to be ../, since that is the relative path to public from public/jam, and will let me require files from the correct paths. However, the generated require.js doesn't contain a baseUrl property, so scripts are being required relative to the directory from data-main in my script tags.

How can I make jamjs generate requirejs files with the baseUrl properly set?

Robert Mazan

I've also ran into this, except that I wanted to use the same require.js not only in the project root but also in "deeper" folders (for example: pages/index.html). Finally I worked out that if you define a RequireJS config object right before you include RequireJS, you can alter the baseUrl property successfully:

<script>var require = {baseUrl: "../"};</script>
<script src="../resources/libs/require.js"></script>
<script>require(['less', 'bootstrap']);</script>
Martin Etmajer

The documentation clearly says that jam.baseUrl can be used in order to set the baseUrl property of require.js.

Inspecting require.config.js and the configuration block at the end of require.js (as generated by jam) it shows that the baseUrl property is left undefined and further that it does not get passed on to require.config(). I'd consider this a bug.

@caolan: can we expect a fix soon? Thanks!

zzswang

I ran into this problem too.
Thanks to robmazan:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.