Skip to content

Commit b506919

Browse files
author
Jacob Wejendorp
committed
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.
1 parent 794b602 commit b506919

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
background: red;
3+
background-image: url(c9e192c015437a21dea1.svg);
4+
}
5+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './style.css';
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
background: red;
3+
background-image: url(./react.svg);
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const webpack = require('webpack');
2+
3+
module.exports = () => webpack.version[0] !== '4';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Self from '../../../src';
2+
3+
/**
4+
* Bug report:
5+
* Setting output.hashSalt together with optimization.realContentHash (e.g. prod mode)
6+
* results in wrong urls for asset-modules.
7+
*/
8+
9+
module.exports = {
10+
entry: './index.js',
11+
output: {
12+
// if salt is omitted, the realContentHash value works in css
13+
hashSalt: 'i break things',
14+
},
15+
optimization: {
16+
// if this is disabled, filenames match even with hashSalt
17+
realContentHash: true,
18+
},
19+
module: {
20+
rules: [
21+
{
22+
test: /\.css$/,
23+
use: [Self.loader, 'css-loader'],
24+
},
25+
{
26+
test: /\.svg$/,
27+
type: 'asset/resource',
28+
},
29+
],
30+
},
31+
plugins: [
32+
new Self({
33+
filename: '[name].css',
34+
}),
35+
],
36+
};

0 commit comments

Comments
 (0)