Skip to content

Commit ca45fd4

Browse files
authored
Merge pull request faceyspacey#42 from zapier/master
Fix css module ordering
2 parents fdbe0e6 + 5e77760 commit ca45fd4

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

index.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
254254
// SETTING THIS TO TRUE INSURES ALL CHUNKS ARE HANDLED:
255255
var shouldExtract = true; //!!(options.allChunks || chunk.isInitial());
256256

257+
chunk.sortModules();
257258
async.forEach(getChunkModulesArray(chunk), function(module, callback) {
258259
var meta = module[NS];
259260
if(meta && (!meta.options.id || meta.options.id === id)) {
@@ -312,16 +313,14 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
312313
// add the css files to assets and the files array corresponding to its chunks
313314
compilation.plugin("additional-assets", function(callback) {
314315
extractedChunks.forEach(function(extractedChunk) {
315-
var extractedChunkModules = getChunkModulesArray(extractedChunk);
316-
317-
if ( extractedChunkModules.length ) {
318-
extractedChunkModules.sort(function(a, b) {
319-
if(!options.ignoreOrder && isInvalidOrder(a, b)) {
320-
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule()));
321-
compilation.errors.push(new OrderUndefinedError(b.getOriginalModule()));
322-
}
323-
return getOrder(a, b);
324-
});
316+
if (extractedChunk.getNumberOfModules()) {
317+
extractedChunk.sortModules((a, b) => {
318+
if (!options.ignoreOrder && isInvalidOrder(a, b)) {
319+
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule()));
320+
compilation.errors.push(new OrderUndefinedError(b.getOriginalModule()));
321+
}
322+
return getOrder(a, b);
323+
});
325324

326325
var stylesheet = this.renderExtractedChunk(extractedChunk);
327326
var chunk = extractedChunk.originalChunk;

0 commit comments

Comments
 (0)