UstymUkhman / vite-plugin-glsl

:spider_web: Import, inline (and compress) GLSL shader files :electric_plug:
https://www.npmjs.com/package/vite-plugin-glsl
MIT License
321 stars 21 forks source link

No loader is configured for ".glsl" in node_modules file #20

Closed fsiddi closed 2 years ago

fsiddi commented 2 years ago

After installing and configuring the plugin, I'm able to require .glsl files, as long as they are part of the application. However, when importing a package (installed in node_modules) which also requires a .glsl file I get an esbuild error:

'No loader is configured for ".glsl" files: node_modules/my-package/glsl/vertex.glsl'

I've been looking at Vite options, esbuild options and could not find a solution, yet. Is this behavior expected?

Edit: found this issue https://github.com/vitejs/vite/issues/1873 which seems related, but I don't fully understand the solution.

UstymUkhman commented 2 years ago

Hi @fsiddi! Thanks for for using this plugin and opening an issue, I guess it seems pretty similar to #18 . Please try the workaround described there and feel free to comment here if that won't work for you. Also, please consider smashing a ⭐if you've found this plugin useful to your purposes, thanks!

fsiddi commented 2 years ago

Thanks for the quick reply. Indeed adding the package to optimizeDeps.exclude helped! As as side note, this means the package I am importing can't use the require keyword for referencing *.glsl paths, but should rather rely on import.

UstymUkhman commented 2 years ago

Thank you, @fsiddi ! I'm glad that worked out well.

As as side note, this means the package I am importing can't use the require keyword for referencing *.glsl paths, but should rather rely on import.

And also thanks for this note. I guess it's related to vite v3.0.0+ that switched to node: imports so this plugin was adapted relatively to this strategy. I've mentioned it briefly in here.