-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set the correct asset_info when extracting css (#8454)
- Loading branch information
Showing
5 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/configCases/css/rspack-issue-8431/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./style.css"; |
43 changes: 43 additions & 0 deletions
43
packages/rspack-test-tools/tests/configCases/css/rspack-issue-8431/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { rspack } = require("@rspack/core"); | ||
|
||
class Plugin { | ||
apply(compiler) { | ||
compiler.hooks.thisCompilation.tap("MyPlugin", compilation => { | ||
compilation.hooks.processAssets.tap( | ||
{ | ||
name: "MyPlugin", | ||
stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH | ||
}, | ||
() => { | ||
const css = compilation | ||
.getAssets() | ||
.find(asset => asset.name.endsWith(".css")); | ||
expect(css.info.contenthash.length).toBeGreaterThan(0); | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
entry: "./index.js", | ||
target: "web", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [rspack.CssExtractRspackPlugin.loader, "css-loader"] | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new rspack.CssExtractRspackPlugin({ | ||
filename: "[name].[contenthash].css" | ||
}), | ||
new Plugin() | ||
], | ||
experiments: { | ||
css: false | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/rspack-test-tools/tests/configCases/css/rspack-issue-8431/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.example { | ||
margin-left: 22px; | ||
margin-top: 22px; | ||
margin-bottom: 22px; | ||
} |
File renamed without changes.
bf83b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
bf83b48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open