You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Setting sourceMap: true generates different content hashes on Linux vs MacOS #886
The generated contenthash for a CSS file is consistent with the content of the file.
Actual Behavior
The generated contenthash differs depending on which operating system Webpack is run on.
I have tried various combinations of adding removing loaders before/after the css-loader (including using style-loader instead of MiniCssExtractPlugin) and the addition/removal of the sourceMap option in css-loader is the thing that triggers this to occur.
The files in the various operating systems have the exact same content. This was verified by generating an MD5 hash of the CSS file.
There's a CircleCI build configured where you can see the "good" and "bad" webpack config running. If you take a look at the generated contenthash (and compare against a compilation on a Mac), you can see they are different
For my Mac, the "good" output is main.faf79bb5bf2915fa1fb9.css and the "bad" output is main.a2f311c836bf5e7db183.css.
Contrast this with the Linux build in CircleCI: "good" output is main.faf79bb5bf2915fa1fb9.css as expected "bad" output is main.64ea49633b59dce4de34.css which differs from the MacOS build.
It is very possible the problem is in Webpack itself. I looked through the code for css-loader and didn't see anything that could potentially be causing this.
Note I have not tried this in Webpack v5 alpha as MiniCssExtractPlugin and HtmlWebpackPlugin are not yet compatible
@evilebottnawi I don't believe that will fix the problem:
A) doesn't the ternary already respect the sourceMap option?
B) Even with that, the sourcemaps are still different on the various operating systems. I think the issue is from the sources array in the sourcemap object. That path is an absolute path, not a relative path, so it could be different from machine to machine. This causes the contenthash to be different.
doesn't the ternary already respect the sourceMap option?
No, we should fix it in plugin
Even with that, the sourcemaps are still different on the various operating systems. I think the issue is from the sources array in the sourcemap object. That path is an absolute path, not a relative path, so it could be different from machine to machine. This causes the contenthash to be different.
Working on this problem #1031, found what it is happens only with sass-loader and sourceMap: true, sorry for big delay in this issue, a lot of issues 😞
Let's close in favor #622, source map improvements will be after stable 4 release. postcss has some bugs, we need wait postcss@8. I want to union all source maps problems in one issue
Activity
alexander-akait commentedon Jan 18, 2019
Thanks for issue, i will investigate this in near future, but i think problem not in
css-loaderwingrunr21 commentedon Jan 18, 2019
It is very possible the problem is in Webpack itself. I looked through the code for
css-loaderand didn't see anything that could potentially be causing this.Note I have not tried this in Webpack v5 alpha as MiniCssExtractPlugin and HtmlWebpackPlugin are not yet compatible
alexander-akait commentedon Jan 22, 2019
@wingrunr21 after investigate i find problem:
With
sourceMap: truecss-loadergenerate:Without
So content hashes are difference. Problem on side
mini-css-extract-pluginhere https://github.com/webpack-contrib/mini-css-extract-plugin/blob/ffb0d87ce68560e2b301a090d257c105f60a969a/src/index.js#L96We should respect
sourceMapoption formini-css-extract-plugin. Open issue #886, feel free to send a PRalexander-akait commentedon Jan 22, 2019
You can comment
And see what
contenthashis same.Just need like:
wingrunr21 commentedon Jan 23, 2019
@evilebottnawi I don't believe that will fix the problem:
A) doesn't the ternary already respect the
sourceMapoption?B) Even with that, the sourcemaps are still different on the various operating systems. I think the issue is from the
sourcesarray in the sourcemap object. That path is an absolute path, not a relative path, so it could be different from machine to machine. This causes thecontenthashto be different.alexander-akait commentedon Jan 23, 2019
@wingrunr21
#652
Unfortunately we have problems with source maps and paths in
sass-loader,postcss-loaderandcss-loader, you can help us.wingrunr21 commentedon Jan 23, 2019
I can try to dig into this but it looks like this has been reported for awhile. Would you mind re-opening this issue as it is not in fact resolved.
alexander-akait commentedon Jan 23, 2019
@wingrunr21
I think we should use
relativepaths forsourcesin source map and always use linux path, need tests how it is works (include windows)wingrunr21 commentedon Jan 23, 2019
Yep, that seems right. I'll see if I have time to dig into it. Looks like there are a few example repos with reproduction steps.
wingrunr21 commentedon Jan 29, 2019
@evilebottnawi Upon looking at this closer, fixes across the various loaders have been submitted already. #753 addresses it for this project
alexander-akait commentedon Jan 29, 2019
@wingrunr21 invalid fix and break source maps
alexander-akait commentedon Mar 6, 2019
To solve this problem we should:
normalize path in(done)sources,sourceRootandfilein source mapmini-css-extract-pluginor maybe passundefinedinstead empty string when source map is not presentalexander-akait commentedon Dec 26, 2019
Working on this problem #1031, found what it is happens only with
sass-loaderandsourceMap: true, sorry for big delay in this issue, a lot of issues 😞alexander-akait commentedon Jul 15, 2020
Let's close in favor #622, source map improvements will be after stable
4release. postcss has some bugs, we need wait postcss@8. I want to union all source maps problems in one issue