I am currently starting development of drupal sites on Acquia. Using git and working locally is a new workflow for me. When building locally and trying to utilize Modernizr load / yepnope, my JS in my script.js file typically looks like this..
Modernizr.load([
{
test: Modernizr.mq('only all'),
nope: '/sitename/docroot/sites/all/themes/theme/js/libs/polyfill.js'
},
....
So that works locally on my machine, but when I commit my changes and push to my acquia development server the file path for the loaded scripts is incorrect, since it's not the same setup I guess.
http://mysite.devcloud.acquia-sites.com/mysite/docroot/sites/all/themes/theme/js/libs/polyfill.js
It needs to be the below, without the mysite/docroot in the URL.
http://mysite.devcloud.acquia-sites.com/sites/all/themes/theme/js/libs/polyfill.js
So that brings me to Drupal.settings.basePath. If I print this out it gives me /mysite/docroot/ on my local setup. If I do it on the dev server, it would print out something different (probably just / ).
So me being the amateur assumed I could do something like this.. (forgive the poor sample, I know it can be done better)
var myroot = Drupal.settings.basePath
Modernizr.load([
{
test: Modernizr.mq('only all'),
nope: myroot + 'sites/all/themes/theme/js/libs/polyfill.js'
},
....
And this of course does not work. Just returns query1 is not defined.
So I am sure there are faults in many of my attempts to make this work.. so if anyone can suggest something to me, either workflow related or how to fix my setup / code, that would be great.
Thanks
Maybe I just have a different local setup when using Acquia, but why not just use a relative path like /sites/all/themes/theme/js/libs/polyfill.js?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With