In my LESS CSS file I define a base-url:
@base-url: 'http://cdn.domain.com';
I now have the need to dynamically switch the base url depending on what environment I am on. Ex:
DEV: 'http://domain.com'
PROD: 'http://cdn.domain.com'
Is there a way to check this directly via LESS or is there a way to pass this variable from PHP to LESS?
You can create two files, one for development, one for production, and compile whichever you need:
/* Production: production.less */
@base-url: 'http://cdn.domain.com';
@import "main.less"
/* Development: dev.less */
@base-url: 'http://dev.domain.com/files';
@import "main.less";
Here is a way to parse php variable to less files.
http://leafo.net/lessphp/docs/#setting_variables_from_php
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