Description
- Operating System: MacOS and Linux
- Node Version: Tested on 9.x and 10.x
- NPM Version: 6.1.0
- webpack Version: ^4.28.4
- css-loader Version: ^2.1.0
Expected Behavior
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.
Code
// webpack.config.good.js
{
test: /\.s?css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader"
},
{ loader: "sass-loader", options: { sourceMap: true } }
]
}
// webpack.config.bad.js
{
test: /\.s?css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: { sourceMap: true }
},
{ loader: "sass-loader", options: { sourceMap: true } }
]
}
How Do We Reproduce?
Please see my example repo
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.