diff --git a/src/index.js b/src/index.js index b266b331..72ba0bdd 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,10 @@ import webpack from 'webpack'; import sources from 'webpack-sources'; const { ConcatSource, SourceMapSource, OriginalSource } = sources; -const { Template, util: { createHash } } = webpack; +const { + Template, + util: { createHash }, +} = webpack; const NS = path.dirname(fs.realpathSync(__filename)); @@ -97,7 +100,12 @@ class CssModule extends webpack.Module { } class CssModuleFactory { - create({ dependencies: [dependency] }, callback) { + create( + { + dependencies: [dependency], + }, + callback + ) { callback(null, new CssModule(dependency)); } } @@ -390,7 +398,11 @@ class MiniCssExtractPlugin { const [chunkGroup] = chunk.groupsIterable; if (typeof chunkGroup.getModuleIndex2 === 'function') { modules.sort( - (a, b) => chunkGroup.getModuleIndex2(a) - chunkGroup.getModuleIndex2(b) + (a, b) => + (chunkGroup.getModuleIndex2(a) || 0) < + (chunkGroup.getModuleIndex2(b) || 0) + ? 1 + : -1 ); } else { // fallback for older webpack versions