Skip to content

Commit

Permalink
caching fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyaleksey committed Nov 4, 2015
1 parent 6f10cfd commit 6981591
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var path = require('path');
var through = require('through');
var extractor = require('./extractor');
var FileSystemLoader = require('css-modules-loader-core/lib/file-system-loader');
var assign = require('object-assign');
var stringHash = require('string-hash');
var ReadableStream = require('stream').Readable;

Expand Down Expand Up @@ -124,12 +123,18 @@ module.exports = function (browserify, options) {
return void reject(err);
}

var tokens = tokensByFile[filename];
if (tokens) {
compiledCssStream.push(sourceByFile[filename]);
return void resolve(tokens);
}

instance.process(css, {from: filename})
.then(function (result) {
var css = result.css;
var tokens = result.root.tokens;

assign(tokensByFile, tokens);
tokensByFile[filename] = tokens;
sourceByFile[filename] = css;
compiledCssStream.push(css);

Expand Down

0 comments on commit 6981591

Please sign in to comment.