diff --git a/lib/less/browser.js b/lib/less/browser.js index 5ac2b93df..9cbe0c113 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -162,6 +162,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) { try { contents[href] = data; // Updating top importing parser content cache new(less.Parser)({ + suffix: sheet.suffix | false, optimization: less.optimization, paths: [href.replace(/[\w\.-]+$/, '')], mime: sheet.type, diff --git a/lib/less/parser.js b/lib/less/parser.js index 6528b3924..2fc0ae8fa 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -76,6 +76,7 @@ less.Parser = function Parser(env) { var imports = this.imports = { paths: env && env.paths || [], // Search paths, when importing + suffix: env && env.suffix || false, //Suffix to append to imported files when loading to bust browser caches queue: [], // Files which haven't been imported yet files: {}, // Holds the imported parse trees contents: env.contents, // Holds the imported file contents @@ -88,7 +89,7 @@ less.Parser = function Parser(env) { // // Import a file asynchronously // - less.Parser.importer(path, this.paths, function (e, root) { + less.Parser.importer(path, this.paths, this.suffix, function (e, root) { that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue var imported = path in that.files; @@ -1481,15 +1482,18 @@ if (less.mode === 'browser' || less.mode === 'rhino') { // // Used by `@import` directives // - less.Parser.importer = function (path, paths, callback, env) { + less.Parser.importer = function (path, paths, suffix, callback, env) { if (!/^([a-z-]+:)?\//.test(path) && paths.length > 0) { path = paths[0] + path; } + if (suffix) { + path = path + suffix; + } // We pass `true` as 3rd argument, to force the reload of the import. // This is so we can get the syntax tree as opposed to just the CSS output, // as we need this to evaluate the current stylesheet. // __ Now using the hack of passing a ref to top parser's content cache in the 1st arg. __ - loadStyleSheet({ href: path, title: path, type: env.mime, contents: env.contents }, function (e) { + loadStyleSheet({ href: path, title: path, suffix: suffix, type: env.mime, contents: env.contents }, function (e) { if (e && typeof(env.errback) === "function") { env.errback.call(null, path, paths, callback, env); } else {