jam icon indicating copy to clipboard operation
jam copied to clipboard

Absolute base URL

Open BrianHicks opened this issue 12 years ago • 1 comments

(disclaimer: I'm a bit new to both Jam and require, trying to figure this out for the first time.)

I'm using Jam with Django. Right now, here's the relevant bits of my package.json:

{
    "jam": {
        "packageDir": "assets",
        "baseUrl": "static",
        "dependencies": {
            "bootstrap": "2.3.1",
            "jquery": "2.0.0",
            "angularjs": "1.0.5",
            "angular-resource": "1.0.1"
        }
    }
}

This makes Jam calculate the paths of the assets as (for example) ../assets/angularjs. What I expected (and in fact need here) is for the path to look like /static/angularjs. (The reasons for this are slightly wonky. Django handles static files by copying them from a different directory in production, and serving them as if they were already copied in development.)

If it's not possible in some way to change this, is there a flag I can set to have Jam leave my require.js and require.config.js alone on installs so I can set the paths manually?

BrianHicks avatar May 07 '13 14:05 BrianHicks

the module managed by Jam needs to be accessible via url as it's loaded asynchronously by require.js. without changing Jam what you could do is to have packageDir to be "assets/static" and baseUrl to be "assets" which will generate your paths to be "static/angularjs". Then in your app.js you could set the baseUrl to be '/' which will give you the right path "/static/angularjs". obviously you would need to have something setup during development to serve "/static/angularjs" from "assets/static/angularjs". you can compile it everything into one js file for production via build pipeline.

Jae avatar Jun 02 '13 23:06 Jae