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

bug: add failing test for hashSalt in prod mode (realContentHash) #778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
@@ -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
@@ -0,0 +1 @@
import './style.css';
1 change: 1 addition & 0 deletions test/cases/asset-modules-salted/react.svg
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
@@ -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
@@ -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
@@ -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',
}),
],
};