-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading external shader file for Webgl #1517
Comments
If you need it as a string, could you just write a JS file exporting a string? export default `
attribute vec4 a_position;
attribute vec2 a_texcoord;
// ...
`; In CRA’s setup, when you import an unrecognized file, you’ll get its URL (which may be a data URL when it’s small enough and inlined). This is useful for media files, but not useful for shaders. Alternatively, you can I hope this helps! |
Thank you for your answer It's not very convenient to maintain shader's code as a string. |
For anyone still looking, It is possible to load shaders from a file with raw-loader and glslify-loader. Glslify supports
|
i have this problem with this solution Failed to compile |
@arpu you must eject to use that solution |
@Timer ok i will eject thx! |
same problem after eject |
ok i can add this as loader after eject but this was not the idea with the raw-loader |
I'm not sure how any of this works so you'll have to defer to @odGit. If you just want the raw text, I'd un-eject and follow advice given here: #1517 (comment). |
#1944 /* eslint import/no-webpack-loader-syntax: off */ |
Hi,
A part of my app use Webgl (with shaders).
I would like to load my shader files in my bundle (instead of write shaders as string inside the JS files).
So I wrote an a file named
shader.vert
which containsThen I try to load it in an other file
but I get this output instead of the original content of my file:
I'm not a very confortable with Webpack (and that's why I love create-react-app).
I mean I know that webpack use many "loaders" etc but I don't really know how they work.
Should I eject and add custom loaders ? (all that I DONT want to do)
Or is there a way to import file as a simple string ?
With
.vert
,.frag
,.glsl
or other extension ?Thanks
The text was updated successfully, but these errors were encountered: