Reputation: 7152
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?
Upvotes: 4
Views: 1852
Reputation: 349052
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";
Upvotes: 7
Reputation: 3516
Here is a way to parse php variable to less files.
http://leafo.net/lessphp/docs/#setting_variables_from_php
Upvotes: 1