-
Notifications
You must be signed in to change notification settings - Fork 219
fix(karma-webpack): handle multiple outputs correctly #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,7 +237,11 @@ Plugin.prototype.readFile = function(file, callback) { | |
var doRead = function() { | ||
if (optionsCount > 1) { | ||
async.times(optionsCount, function(idx, callback) { | ||
middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file]), callback) | ||
if (Array.isArray(this.outputs[file])) { | ||
middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file][0]), callback); | ||
} else { | ||
middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file]), callback); | ||
} | ||
}.bind(this), function(err, contents) { | ||
if (err) { | ||
return callback(err) | ||
|
@@ -253,8 +257,13 @@ Plugin.prototype.readFile = function(file, callback) { | |
callback(null, Buffer.concat(contents)) | ||
}) | ||
} else { | ||
try { | ||
var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. var fileContents = ''
if (condition) {
fileContents = ...
} else {
fileContents = ...
} |
||
try { | ||
var fileContents = '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still off 😛 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe my editor is off 🔢 |
||
if (Array.isArray(this.outputs[file])) { | ||
fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); | ||
} else { | ||
fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])); | ||
} | ||
|
||
callback(undefined, fileContents) | ||
} catch (e) { | ||
|
@@ -297,7 +306,11 @@ function createPreprocesor(/* config.basePath */ basePath, webpackPlugin) { | |
} | ||
|
||
var outputPath = webpackPlugin.outputs[normalize(filename)] | ||
file.path = normalize(path.join(basePath, outputPath)) | ||
if( Array.isArray(outputPath)){ | ||
file.path = normalize(path.join(basePath, outputPath[0])); | ||
} else { | ||
file.path = normalize(path.join(basePath, outputPath)); | ||
} | ||
|
||
done(err, content && content.toString()) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ensured that
this.outputs[file][0]
points to the 'correct' file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try it it with e.g source maps enabled and/or extracting CSS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it with both cases, it works very well :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright :), I need to rely upon you here since this module has no test 😥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, It seems that it is not always the case for some webpack config :(
So i had to fix this in #360