refactor(lqip-loader): remove unused palette option (#6992)

This commit is contained in:
Joshua Chen 2022-03-25 10:23:42 +08:00 committed by GitHub
parent 395136a731
commit d3065b8ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 469 deletions

View file

@ -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!
```