-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- feat: add `parsedValue` argument as an array of parsed filenames w/o URL query, in the `filter()` function of the `sources` - fix(BREAKING CHANGE): for `srcset` attribute the type of the `value` argument is now `string` (was as `Array<string>`), in the `filter()` function of the `sources`, #36\ Note: for `srcset` attribute you can use the `parsedValue` as an array instead of the `value`, the `value` contains now an original string - docs: fix attributes type
- Loading branch information
Showing
36 changed files
with
160 additions
and
66 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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
12 changes: 12 additions & 0 deletions
12
test/cases/loader-option-sources-filter-parsedValues/expected/index.html
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<!-- this data-srcset should be resolved --> | ||
<img src="assets/img/apple.02a7c382.png" data-srcset="assets/img/fig.c6809878.png, assets/img/fig2.c6809878.png 100w, assets/img/fig3.c6809878.png 1.5x"> | ||
<!-- this data-srcset should not be resolved --> | ||
<img src="@images/pear.png?size=300" data-srcset="@images/lemon.png?size=200, @images/lemon2.png 100w, @images/lemon3.png 1.5x"> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
test/cases/loader-option-sources-filter-parsedValues/src/index.html
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<!-- this data-srcset should be resolved --> | ||
<img src="@images/apple.png" data-srcset="@images/fig.png, @images/fig2.png 100w, @images/fig3.png 1.5x"> | ||
<!-- this data-srcset should not be resolved --> | ||
<img src="@images/pear.png?size=300" data-srcset="@images/lemon.png?size=200, @images/lemon2.png 100w, @images/lemon3.png 1.5x"> | ||
</body> | ||
</html> |
50 changes: 50 additions & 0 deletions
50
test/cases/loader-option-sources-filter-parsedValues/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,50 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('../../../'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
resolve: { | ||
alias: { | ||
'@images': path.join(__dirname, '../../fixtures/images'), | ||
}, | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
entry: { | ||
index: './src/index.html', | ||
}, | ||
loaderOptions: { | ||
sources: [ | ||
{ | ||
tag: 'img', | ||
attributes: ['data-srcset'], | ||
// test parsedValue | ||
filter: ({ attribute, value, parsedValue }) => { | ||
//console.log('\n### filter attributes: ', { attribute, value, parsedValue }); | ||
if (attribute === 'src' && parsedValue.includes('@images/pear.png')) return false; | ||
if (attribute === 'data-srcset' && parsedValue.includes('@images/lemon.png')) return false; | ||
}, | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|jpe?g|ico|svg)$/, | ||
type: 'asset/resource', | ||
generator: { | ||
filename: 'assets/img/[name].[hash:8][ext][query]', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+1.74 KB
test/cases/loader-option-sources-filter/expected/assets/img/apple.02a7c382.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 KB
test/cases/loader-option-sources-filter/expected/assets/img/fig.c6809878.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 KB
test/cases/loader-option-sources-filter/expected/assets/img/fig2.c6809878.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 KB
test/cases/loader-option-sources-filter/expected/assets/img/fig3.c6809878.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
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
Binary file added
BIN
+484 Bytes
test/cases/responsive-images-html-css/expected/assets/img/apple-60w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+548 Bytes
test/cases/responsive-images-html-css/expected/assets/img/apple-70w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.