Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ module.exports = function (browserify, options) {

var cssOutFilename = options.output || options.o;
var jsonOutFilename = options.json || options.jsonOutput;
var sourceKey = cssOutFilename;

// keying our source caches by the name of our output file means we can
// isolate css compilation of seperate bundles that are running in parallel
sourceByFile[sourceKey] = sourceByFile[sourceKey] || {};

// PostCSS plugins passed to FileSystemLoader
var plugins = options.use || options.u;
Expand Down Expand Up @@ -166,7 +171,7 @@ module.exports = function (browserify, options) {
assign(tokensByFile, loader.tokensByFile);

// store this file's source to be written out to disk later
sourceByFile[filename] = loader.finalSource;
sourceByFile[sourceKey][filename] = loader.finalSource;

compiledCssStream.push(loader.finalSource);

Expand All @@ -190,8 +195,8 @@ module.exports = function (browserify, options) {
bundle.emit('css stream', compiledCssStream);

bundle.on('end', function () {
// Combine the collected sources into a single CSS file
var files = Object.keys(sourceByFile);
// Combine the collected sources for a single bundle into a single CSS file
var files = Object.keys(sourceByFile[sourceKey]);
var css;

// end the output stream
Expand All @@ -200,7 +205,7 @@ module.exports = function (browserify, options) {
// write the css file
if (cssOutFilename) {
css = files.map(function (file) {
return sourceByFile[file];
return sourceByFile[sourceKey][file];
}).join('\n');

fs.writeFile(cssOutFilename, css, function (err) {
Expand Down