-
-
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.
feat: add
emit
option for asset modules (#6255)
- Loading branch information
1 parent
98e4a72
commit 2320840
Showing
18 changed files
with
249 additions
and
8 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
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
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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
packages/rspack/tests/configCases/asset/disable-emit-by-rule/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,12 @@ | ||
import url from "../_images/file.png"; | ||
import url2 from "../_images/file.jpg"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
it("should not output asset when emit is false", () => { | ||
expect(url).toEqual("images/file.png"); | ||
expect(url2).toEqual("images/file.jpg"); | ||
|
||
expect(fs.existsSync(path.join(__STATS__.outputPath, url))).toBe(false); | ||
expect(fs.existsSync(path.join(__STATS__.outputPath, url2))).toBe(true); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/rspack/tests/configCases/asset/disable-emit-by-rule/webpack.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,22 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
context: __dirname, | ||
output: { | ||
assetModuleFilename: "images/file[ext]" | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.png$/, | ||
type: "asset/resource", | ||
generator: { | ||
emit: false | ||
} | ||
}, | ||
{ | ||
test: /\.jpg$/, | ||
type: "asset/resource" | ||
} | ||
] | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/rspack/tests/configCases/asset/disable-emit-for-asset/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,12 @@ | ||
import url from "../_images/file.png"; | ||
import url2 from "../_images/file.jpg"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
it("should not output asset when emit is false", () => { | ||
expect(url).toEqual("images/file.png"); | ||
expect(url2).toEqual("images/file.jpg"); | ||
|
||
expect(fs.existsSync(path.join(__STATS__.outputPath, url))).toBe(false); | ||
expect(fs.existsSync(path.join(__STATS__.outputPath, url2))).toBe(false); | ||
}); |
Oops, something went wrong.
2320840
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
2320840
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