diff --git a/lib/link-less.js b/lib/link-less.js
index 3be6841..1d87ff6 100644
--- a/lib/link-less.js
+++ b/lib/link-less.js
@@ -1,6 +1,7 @@
const co = require('co');
const fs = require('mz/fs');
const isLocalPath = require('is-local-path');
+const isTemplateExpression = require('./is-template-expression');
const less = require('less');
const path = require('path');
const R = require('ramda');
@@ -38,7 +39,10 @@ const inlineLess = co.wrap(function * ($, filename, options) {
var files = [];
try {
const links = $('link[rel="stylesheet/less"]')
- .filter((index, link) => isLocalPath($(link).attr('href')))
+ .filter((index, link) => {
+ const href = $(link).attr('href');
+ return isLocalPath(href) && !isTemplateExpression(href);
+ })
.toArray();
const getHref = element => path.resolve(basedir, $(element).attr('href'));
const hrefs = R.map(getHref, links);
diff --git a/test/fixtures/nested-import.less b/test/fixtures/nested-import.less
new file mode 100644
index 0000000..73a6cfd
--- /dev/null
+++ b/test/fixtures/nested-import.less
@@ -0,0 +1 @@
+@import 'import.less';
diff --git a/test/index.js b/test/index.js
index c9f54df..34526cc 100644
--- a/test/index.js
+++ b/test/index.js
@@ -275,16 +275,16 @@ describe('inline-html', () => {
});
describe('img', () => {
- it('inline img src', () => {
+ it('inline local source', () => {
const filename = path.resolve(__dirname, 'fixtures/file.txt');
const html = `
`;
return expect(inline.html(html)).to.eventually.match(/data:.*,.*/);
});
- it('ignore img src remote paths', () => {
+ it('ignore remote source', () => {
const html = `
`;
return expect(inline.html(html)).to.eventually.equal(html);
});
- it('ignore img src template expression paths', () => {
+ it('ignore template expression source', () => {
const html = `
`;
return expect(inline.html(html)).to.eventually.equal(html);
});
@@ -325,20 +325,28 @@ describe('inline-html', () => {
});
describe('link-less', () => {
- it('inline link less', () => {
+ it('inline local href', () => {
const filename = path.resolve(__dirname, 'fixtures/basic.less');
const html = ``;
return expect(inline.html(html)).to.eventually.match(/