mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
refactor(lqip-loader): remove unused palette option (#6992)
This commit is contained in:
parent
395136a731
commit
d3065b8ad2
8 changed files with 20 additions and 469 deletions
|
@ -10,7 +10,7 @@ npm install --save-dev @docusaurus/lqip-loader
|
|||
|
||||
## Example
|
||||
|
||||
Generating Base64 & dominant colours palette for a jpeg image imported in your JS bundle:
|
||||
Generating Base64 for a jpeg image imported in your JS bundle:
|
||||
|
||||
> The large image file will be emitted & only 400byte of Base64 (if set to true in the loader options) will be bundled.
|
||||
|
||||
|
@ -26,8 +26,6 @@ Generating Base64 & dominant colours palette for a jpeg image imported in your J
|
|||
options: {
|
||||
path: '/media', // your image going to be in media folder in the output dir
|
||||
name: '[name].[ext]', // you can use [contenthash].[ext] too if you wish,
|
||||
base64: true, // default: true, gives the base64 encoded image
|
||||
palette: true // default: false, gives the dominant colours palette
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -35,13 +33,7 @@ Generating Base64 & dominant colours palette for a jpeg image imported in your J
|
|||
// OPTION B: Chained with your own url-loader or file-loader
|
||||
test: /\.(png|jpe?g)$/,
|
||||
loaders: [
|
||||
{
|
||||
loader: '@docusaurus/lqip-loader',
|
||||
options: {
|
||||
base64: true,
|
||||
palette: false
|
||||
}
|
||||
},
|
||||
'@docusaurus/lqip-loader',
|
||||
{
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
|
@ -60,9 +52,6 @@ import banner from './images/banner.jpg';
|
|||
console.log(banner.preSrc);
|
||||
// outputs: "data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhY....
|
||||
|
||||
// the object will have palette property, array will be sorted from most dominant colour to the least
|
||||
console.log(banner.palette); // [ '#628792', '#bed4d5', '#5d4340', '#ba454d', '#c5dce4', '#551f24' ]
|
||||
|
||||
console.log(banner.src); // that's the original image URL to load later!
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue