Skip to content
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

fix(index): correct order of CSS imports #242

Closed
wants to merge 4 commits into from
Closed
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
18 changes: 15 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -97,7 +100,12 @@ class CssModule extends webpack.Module {
}

class CssModuleFactory {
create({ dependencies: [dependency] }, callback) {
create(
{
dependencies: [dependency],
},
callback
) {
callback(null, new CssModule(dependency));
}
}
Expand Down Expand Up @@ -390,7 +398,11 @@ class MiniCssExtractPlugin {
const [chunkGroup] = chunk.groupsIterable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here only the first chunkGroup is used. Maybe this need to be reconsidered. See also comment above.

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
Expand Down