Skip to content
Closed
Show file tree
Hide file tree
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
test: add failing test for hashSalt in prod mode (realContentHash)
Setting output.hashSalt together with optimization.realContentHash (e.g. prod mode)
results in wrong urls for asset-modules, resulting in broken bundles.

Added test seems to be minimum to reproduce.
  • Loading branch information
Jacob Wejendorp committed Jun 30, 2021
commit b5069197ff2fbed1a9e4736b24594594197b3c06
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/cases/asset-modules-salted/expected/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
background: red;
background-image: url(c9e192c015437a21dea1.svg);
}

1 change: 1 addition & 0 deletions test/cases/asset-modules-salted/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './style.css';
1 change: 1 addition & 0 deletions test/cases/asset-modules-salted/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/cases/asset-modules-salted/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: red;
background-image: url(./react.svg);
}
3 changes: 3 additions & 0 deletions test/cases/asset-modules-salted/test.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const webpack = require('webpack');

module.exports = () => webpack.version[0] !== '4';
36 changes: 36 additions & 0 deletions test/cases/asset-modules-salted/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Self from '../../../src';

/**
* Bug report:
* Setting output.hashSalt together with optimization.realContentHash (e.g. prod mode)
* results in wrong urls for asset-modules.
*/

module.exports = {
entry: './index.js',
output: {
// if salt is omitted, the realContentHash value works in css
hashSalt: 'i break things',
},
optimization: {
// if this is disabled, filenames match even with hashSalt
realContentHash: true,
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
{
test: /\.svg$/,
type: 'asset/resource',
},
],
},
plugins: [
new Self({
filename: '[name].css',
}),
],
};