mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
change default for useFileCache. Fixes #2261
This commit is contained in:
@@ -80,6 +80,10 @@ FileManager.prototype.supports = function(filename, currentDirectory, options, e
|
||||
return true;
|
||||
};
|
||||
|
||||
FileManager.prototype.clearFileCache = function() {
|
||||
fileCache = {};
|
||||
};
|
||||
|
||||
FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment) {
|
||||
return new PromiseConstructor(function(fullfill, reject) {
|
||||
if (currentDirectory && !this.isPathAbsolute(filename)) {
|
||||
|
||||
@@ -68,6 +68,10 @@ if (dumpLineNumbers) {
|
||||
options.dumpLineNumbers = dumpLineNumbers[1];
|
||||
}
|
||||
|
||||
if (options.useFileCache === undefined) {
|
||||
options.useFileCache = true;
|
||||
}
|
||||
|
||||
var typePattern = /^text\/(x-)?less$/;
|
||||
|
||||
function postProcessCSS(styles) {
|
||||
@@ -108,10 +112,6 @@ function loadStyles(modifyVars) {
|
||||
var lessText = style.innerHTML || '';
|
||||
instanceOptions.filename = document.location.href.replace(/#.*$/, '');
|
||||
|
||||
if (modifyVars || instanceOptions.globalVars) {
|
||||
instanceOptions.useFileCache = true;
|
||||
}
|
||||
|
||||
/*jshint loopfunc:true */
|
||||
// use closure to store current style
|
||||
less.render(lessText, instanceOptions)
|
||||
@@ -138,9 +138,6 @@ function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
||||
if (modifyVars) {
|
||||
instanceOptions.modifyVars = modifyVars;
|
||||
}
|
||||
if (modifyVars || options.globalVars) {
|
||||
instanceOptions.useFileCache = true;
|
||||
}
|
||||
|
||||
fileManager.loadFile(sheet.href, null, instanceOptions, environment)
|
||||
.then(function loadInitialFileCallback(loadedFile) {
|
||||
@@ -198,6 +195,7 @@ function initRunningMode(){
|
||||
if (less.env === 'development') {
|
||||
less.watchTimer = setInterval(function () {
|
||||
if (less.watchMode) {
|
||||
fileManager.clearFileCache();
|
||||
loadStyleSheets(function (e, css, _, sheet, context) {
|
||||
if (e) {
|
||||
errors.add(e, e.href || sheet.href);
|
||||
@@ -258,6 +256,9 @@ less.modifyVars = function(record) {
|
||||
};
|
||||
|
||||
less.refresh = function (reload, modifyVars) {
|
||||
if (reload) {
|
||||
fileManager.clearFileCache();
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
var startTime, endTime, totalMilliseconds;
|
||||
startTime = endTime = new Date();
|
||||
|
||||
Reference in New Issue
Block a user