cnkt
cnkt

Reputation: 2973

Using variables in import directive for LESS

I can't find a way to use variables in import directive for LESS.

I have got a @cdnUri variable which gets it's value from JavaScript:

@cdnUri: `window.cdnUri`;

cdnUri can be http://localhost/cdn in development mode or http://cdn.example.com in production mode.

What i want is importing other LESS file with this Urls prepended. Like this:

@import "@{cdnUri}/shared/twitter-bootstrap/less/bootstrap.less"

But it gives me this error because it doesn't parse the variables from url.

Couldn't load http://wordy/ui/frontend/themes/default2/ui/css/@{cdnUri}/ui/shared/js/twitter-bootstrap/less/bootstrap.less (404)

Thanks in advance.

Upvotes: 4

Views: 2440

Answers (2)

peterh
peterh

Reputation: 12573

It is a known less.js bug. It was a year to partially fix it.

Here is what you want:

LESS CSS, @import path from variable

Talk about this bug.

https://github.com/cloudhead/less.js/pull/1108

And here are the new sources.

Upvotes: 1

Digitalex
Digitalex

Reputation: 1494

This isn't a direct answer to your question, but LESS imports are always relative to the current file, so it's not possible to import from another domain.

Upvotes: 3

Related Questions