@@ -99,7 +99,7 @@ module.exports = function (browserify, options) {
99
99
100
100
var cssOutFilename = options . output || options . o ;
101
101
var jsonOutFilename = options . json || options . jsonOutput ;
102
- var sourceKey = cssOutFilename ;
102
+ transformOpts . cssOutFilename = cssOutFilename ;
103
103
104
104
// PostCSS plugins passed to FileSystemLoader
105
105
var plugins = options . use || options . u ;
@@ -142,16 +142,11 @@ module.exports = function (browserify, options) {
142
142
return plugin ;
143
143
} ) ;
144
144
145
- // get (or create) a loader for this entry file
146
- var loader = loadersByFile [ sourceKey ] ;
147
- if ( ! loader ) {
148
- loader = loadersByFile [ sourceKey ] = new FileSystemLoader ( rootDir , plugins ) ;
145
+ // create a loader for this entry file
146
+ if ( ! loadersByFile [ cssOutFilename ] ) {
147
+ loadersByFile [ cssOutFilename ] = new FileSystemLoader ( rootDir , plugins ) ;
149
148
}
150
149
151
- // the compiled CSS stream needs to be avalible to the transform,
152
- // but re-created on each bundle call.
153
- var compiledCssStream ;
154
-
155
150
// TODO: clean this up so there's less scope crossing
156
151
Cmify . prototype . _flush = function ( callback ) {
157
152
var self = this ;
@@ -160,6 +155,9 @@ module.exports = function (browserify, options) {
160
155
// only handle .css files
161
156
if ( ! this . isCssFile ( filename ) ) { return callback ( ) ; }
162
157
158
+ // grab the correct loader
159
+ var loader = loadersByFile [ this . _cssOutFilename ] ;
160
+
163
161
// convert css to js before pushing
164
162
// reset the `tokensByFile` cache
165
163
var relFilename = path . relative ( rootDir , filename ) ;
@@ -203,13 +201,14 @@ module.exports = function (browserify, options) {
203
201
204
202
browserify . on ( 'bundle' , function ( bundle ) {
205
203
// on each bundle, create a new stream b/c the old one might have ended
206
- compiledCssStream = new ReadableStream ( ) ;
204
+ var compiledCssStream = new ReadableStream ( ) ;
207
205
compiledCssStream . _read = function ( ) { } ;
208
206
209
207
bundle . emit ( 'css stream' , compiledCssStream ) ;
210
208
211
209
bundle . on ( 'end' , function ( ) {
212
210
// Combine the collected sources for a single bundle into a single CSS file
211
+ var loader = loadersByFile [ cssOutFilename ] ;
213
212
var css = loader . finalSource ;
214
213
215
214
// end the output stream
0 commit comments