You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am seeking a solution to optimize my assets images and found this new plugin which looks promising, however, it does not work for me.
This is how I tried to configure my config-overrides.js:
constrewireDefinePlugin=require('@yeutech-lab/react-app-rewire-define-plugin');module.exports={
config.rules=(config.rules||[]).concat([{test: /\.(png|jpe?g|gif|svg|webp)$/i,use: [{loader: 'optimized-images-loader',options: {// see below for available options},},],},]);returnconfig;},};
This is the error I have:
Invalidconfigurationobject.WebpackhasbeeninitialisedusingaconfigurationobjectthatdoesnotmatchtheAPIschema.-configurationhasanunknownproperty'rules'.Thesepropertiesare valid:
object{amd?,bail?,cache?,context?,dependencies?,devServer?,devtool?,entry?,externals?,infrastructureLogging?,loader?,mode?,module?,name?,node?,optimization?,output?,parallelism?,performance?,plugins?,profile?,recordsInputPath?,recordsOutputPath?,recordsPath?,resolve?,resolveLoader?,serve?,stats?,target?,watch?,watchOptions? }Fortypos: pleasecorrectthem.Forloaderoptions: webpack>=v2.0.0nolongerallowscustompropertiesinconfiguration.Loadersshouldbeupdatedtoallowpassingoptionsvialoaderoptionsinmodule.rules.UntilloadersareupdatedonecanusetheLoaderOptionsPlugintopasstheseoptionstotheloader:
plugins: [newwebpack.LoaderOptionsPlugin({// test: /\.xxx$/, // may apply this only for some modulesoptions: {rules: …}})]
I compared the version and you also use webpack 4. Do you have a clue why I am not able to use this plugin?
Thanks for sharing!
Edit
I manage to get it work with:
config.module.rules=(config.module.rules||[]).concat([{// test: /\.(png|jpe?g|gif|svg|webp)$/i,test: /\.(png|jpe?g|gif|webp)$/i,use: [{loader: 'optimized-images-loader',options: {includeStrategy: 'react',// see below for available options},},],},]);
However, all my images are now broken in my app. I checked what an import was bringing and it's a base64 (apparently wrong string). So I wanted to verified if it worked well, I have added ?colors at the end of the image import:
I expect an hex colors, instead, I still have the base64 image: data:image/jpeg;base64,dmFyIHJlcz1bIiNkOGQ4ZDgiLCIjMjYyNjI2IiwiIzk3OTc5NyIsIiM3MjcyNzIiLCIjOGM4YzhjIl07cmVzLndpZHRoPTY0MDtyZXMuaGVpZ2h0PTQyNTtyZXMuZm9ybWF0PSJqcGVnIjttb2R1bGUuZXhwb3J0cyA9IHJlczs=
I expect an hex colors, instead, I still have the base64 image: data:image/jpeg;base64,dmFyIHNyYyA9IF9fd2VicGFja19wdWJsaWNfcGF0aF9fICsgImFyY2hpdGVjdHVyZS0xMzU0ODExXzY0MC1tZC0xYWEwYmY4YWU3MDAzMzJhZGVhNTNmMTZlNTAwM2MzZC5qcGciO21vZHVsZS5leHBvcnRzPXtzcmM6c3JjLHdpZHRoOjY0MCxoZWlnaHQ6NDI1LGZvcm1hdDoianBlZyIsdG9TdHJpbmc6ZnVuY3Rpb24oKXtyZXR1cm4gc3JjO319Ow==
I have tried to decode this base64 online and the import is text/plain:
I am working within a create-react-app, using
[email protected]
and[email protected]
.I am seeking a solution to optimize my assets images and found this new plugin which looks promising, however, it does not work for me.
This is how I tried to configure my
config-overrides.js
:This is the error I have:
I compared the version and you also use webpack 4. Do you have a clue why I am not able to use this plugin?
Thanks for sharing!
Edit
I manage to get it work with:
However, all my images are now broken in my app. I checked what an import was bringing and it's a
base64
(apparently wrong string). So I wanted to verified if it worked well, I have added?colors
at the end of the image import:I expect an hex colors, instead, I still have the base64 image:
data:image/jpeg;base64,dmFyIHJlcz1bIiNkOGQ4ZDgiLCIjMjYyNjI2IiwiIzk3OTc5NyIsIiM3MjcyNzIiLCIjOGM4YzhjIl07cmVzLndpZHRoPTY0MDtyZXMuaGVpZ2h0PTQyNTtyZXMuZm9ybWF0PSJqcGVnIjttb2R1bGUuZXhwb3J0cyA9IHJlczs=
I expect an hex colors, instead, I still have the base64 image:
data:image/jpeg;base64,dmFyIHNyYyA9IF9fd2VicGFja19wdWJsaWNfcGF0aF9fICsgImFyY2hpdGVjdHVyZS0xMzU0ODExXzY0MC1tZC0xYWEwYmY4YWU3MDAzMzJhZGVhNTNmMTZlNTAwM2MzZC5qcGciO21vZHVsZS5leHBvcnRzPXtzcmM6c3JjLHdpZHRoOjY0MCxoZWlnaHQ6NDI1LGZvcm1hdDoianBlZyIsdG9TdHJpbmc6ZnVuY3Rpb24oKXtyZXR1cm4gc3JjO319Ow==
I have tried to decode this base64 online and the import is
text/plain
:How can I configure
optimized-images-loader
?The text was updated successfully, but these errors were encountered: