malchata / rollup-plugin-imagemin

Imagemin meets Rollup!
25 stars 7 forks source link

Normalise the path passed with load(id) #15

Closed hwmaier closed 3 years ago

hwmaier commented 3 years ago

Without this mod, the plugin will not work with Vite on Windows as Vite does not pass down a drive letter and the path has Unix style separators. As a result on Windows filter matching (include, exclude patterns) is broken and also the preserveTree configuration parameter won't match. Once the id is converted to the native representation, include/exclude filters work and also the preserveTree configuration can be set for example to preserveTree: 'src' which will nicley regenerate the relative path structure in a Vue/Vite project, so src/assets/image.png becomes dist/assets/image.png.

hwmaier commented 3 years ago

Refer to https://github.com/vitejs/vite/issues/1657

malchata commented 3 years ago

I deeply apologize for the delay in merging this @hwmaier. I had some watch settings for repositories that were burying notifications for this repo and it slipped.

I published an update to this package you may use to test. To ensure I don't unintentionally break dependent applications through a normal install, I published a version containing these (and other) proposed changes to the package's next tag, which you can install as npm i rollup-plugin-imagemin@next. Once you (and other PR submitters) are satisfied, I will republish the package without the next tag.

Please also note that, due to a recently added warning in Rollup, the default export has been dropped and is now a single named export named imagemin. You can check the README for exact usage details.