mini-asset icon indicating copy to clipboard operation
mini-asset copied to clipboard

Variables in LESS imports.

Open berarma opened this issue 8 years ago • 4 comments

I've just noticed mini-asset won't find dependencies declared with an import that uses a variable in LESS.

I must say I don't really need this to work since the files I'm importing are vendor files that I won't change. Touching my files is enough to rebuild it. Just noticed it and thought I would report about it.

This will be hard to fully resolve. A possible workaround would be to have an option to disable incremental building or a configurable path to check for changes on any file inside it.

berarma avatar Feb 09 '16 12:02 berarma

Could you give an example/sample of problematic files? Are you using node LESS, or the PHP implementations?

markstory avatar Feb 09 '16 17:02 markstory

This is a simple example:

@root-dir: vendor/twbs/bootstrap/less;
@import "@{root-dir}/bootstrap.less";

I'm using node LESS. Compilation works well, it's only that the incremental builds fail to see changes on files imported in this way. Since this imports have to be resolved at compile time I guess it would be hard to know the exact dependencies before compiling.

berarma avatar Feb 09 '16 18:02 berarma

Ah ok. Resolving those variable imports will be nigh on impossible without a sophisticated CSS parser. While the code you have could be solved, other cases like

// variables.less
@rootdir: some/path

// app.less
@import 'variables.less';
@import "@{rootdir}/other.less";

Will not be handled as easily.

markstory avatar Feb 10 '16 02:02 markstory

I came across this issue while trying to work around issue #21. I don't really need it. Given the complexity of a proper fix, and because it's only affecting the incremental builds, I think this could wait. One easy way to deal with filter dependencies that are hard to solve like this one would be using the workarounds I proposed in my first message or something alike.

berarma avatar Mar 14 '16 09:03 berarma