Closed ferlores closed 10 years ago
Strange, I serve all my files using outputDirUrl as the option where I Inform the /context-path
So, outputDirUrl isnt enough in your case?
I'm using absolute paths for the outputDir (since my project is using springMVC and I have to do some tricks with the directories). Anyways it seems that the url is always replaced by /parcelNumber/bundlefile/...
, that's why I need this change
Hi @ferlores ! Thanks for this new PR!
I'm unclear though.. what is the difference between this new baseUrl
option and the existing outputDirUrl
option. At first glance they look like the exact same semantics and are being used in the same way. Why does the outputDirUrl
not work for your case?
Hi @dgbeck,
I've tried to explain it in the PR description. In all the tests that I did I never got the urls in the css files replaced with outputDirUrl
.
This is how I execute cartero
absolutePathToParcels = '/Users/ferlores/myproject/src/main/webapp/app/pages/'
absolutePathToAssetDir = '/Users/ferlores/myproject/src/main/webapp/app/assets/'
var bundler = cartero(absolutePathToParcels, absolutePathToAssetDir, {
baseUrl: '/app/assets'
});
The webserver is exposing /Users/ferlores/myproject/src/main/webapp
as the root directory. In a css file like this one:
a {
background: url(./img/masterSprite.png)
}
With my change I get the URL that I need (/app/assets/xxxx/img/masterSprite.png
). Without my change I get: /xxxx/img/masterSprite.png
If there's another way to achieve this I'm happy to hear it :) Thanks!
Hi @ferlores !
To confirm, when you run cartero like this:
absolutePathToParcels = '/Users/ferlores/myproject/src/main/webapp/app/pages/'
absolutePathToAssetDir = '/Users/ferlores/myproject/src/main/webapp/app/assets/'
var bundler = cartero(absolutePathToParcels, absolutePathToAssetDir, {
outputDirUrl: '/app/assets'
});
You get the URL /xxxx/img/masterSprite.png
?
When I run it like you said I get this:
Error: ENOENT, mkdir '/usr/local/lib/node_modules/gulp/bin/app/assets'
It seems it is trying to create the outputDir in the node_module/gulp directory.
EDIT
@dgbeck Disregard that message. You are right, with outputDirUrl in the options worked perfectly. I dont know why it didn't work before, it seems I had something else wrong. Thanks for your help, I will close this PR
:+1:
Hi, Thanks for merging the other pull request :)
Here If found another use case of interest: in my app I'm serving the
/assets
directory under an specific url (let's sayhttp://my.domain/app/assets/
), but the assetResolver transform is replacing all the url(...) links in the css for the url in the asset folder as an absolute url (ie/f2e88779520b983cdd117bce5129c80e6f271623/img/masterSprite.png
).I need to tell the resolver that I'm serving those files in
http://my.domain/app/assets/f2e88779520b983cdd117bce5129c80e6f271623/img/masterSprite.png
instead. I think that having an extra option called baseUrl will make the trick, what do you think?Thanks! F