-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Environment
- platform: all
- unplugin version: 1.16.1
- nodejs: 20.19.2
- package manager: [email protected]
Reproduction
Repo: https://github.com/Loccko/unplugin-webpack-issues/tree/main
To reproduce:
- Clone
npm cinpm run build:webpack- Try to open images/font from
distfolder
Describe the bug
When using @intlify/unplugin-vue-i18n, unplugin corrupts all binary files (e.g., .jpg, .png, .svg) in the project, which then cannot be used in Vue components.
The root cause is unplugin/dist/webpack/loaders/load.js, which during execution calls the loader from @intlify/unplugin-vue-i18n. This loader does nothing with the source of these files (since the loader's condition check doesn't match). Subsequently, unplugin/dist/webpack/loaders/load checks the result of the unplugin-vue-i18n loader execution, which is undefined, and unplugin/dist/webpack/loaders/load calls the callback with the original input source.
Original code: https://github.com/unjs/unplugin/blob/v1.16.1/src/webpack/loaders/load.ts
Since unplugin/dist/webpack/loaders/load.js lacks the raw = true variable, webpack treats the source as regular text content and attempts to process it as text rather than binary data.
Info: https://webpack.js.org/api/loaders/#raw-loader
This results in corruption of all binary files, leading to broken image and font files that cannot be used.
Note: This issue appears to be relevant for both [email protected] and [email protected], as both major versions lack this variable.
Additional context
No response
