DeMoorJasper / parcel-plugin-imagemin

Parcel image minification plugin
MIT License
129 stars 7 forks source link

Doesn't work with glob requires? #90

Closed pyrossh closed 4 years ago

pyrossh commented 4 years ago

I load all my png images like this,

const images = require('../assets/images/projects/**/*.png');

and it works. So I wanted to compress them also and I added parcel-plugin-imagemin and now I get this error in the console and nothing seems to load,

Unhandled Promise Rejection: Error: Cannot find module 'assets/images/projects/Numberz/app1.png'

It seems the plugin doesn't respect relative paths I think.

Directory structure is here: https://github.com/pyros2097/website/tree/master/assets/images/projects

parcel-bundler: "^1.12.4"

DeMoorJasper commented 4 years ago

This is a known issue, it has been fixed before but I undid the change as it would emit a JS file for each image, there's probably a better way to fix it and maybe should even be fixed within Parcel core but Parcel 1 is in maintenance mode.

Related fix: 0f94a7485b5b462bdfba1120ab0688604b330ab6

You could use an old version of this plugin 3.0.0

pyrossh commented 4 years ago

Thanks. Will try the old version and see if it works. And find an alternative to compress the png assests.

DeMoorJasper commented 4 years ago

Why do you need an alternative? The old version should just work fine and compress your png assets

pyrossh commented 4 years ago

Ohh yeah I thought the old version might fail with the current parcel version. It worked. Thanks.