Skip to content
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

how can i remove comments like // or /* */ #44

Closed
boythl opened this issue Aug 2, 2023 · 3 comments
Closed

how can i remove comments like // or /* */ #44

boythl opened this issue Aug 2, 2023 · 3 comments
Assignees
Labels
not an issue Something that doesn't need to be fixed

Comments

@boythl
Copy link

boythl commented Aug 2, 2023

hi guys, i have set compress to true in my vite.config.ts,
but when i build the project, comments are still here; Eg:

uniform float uRange; // \u5C55\u793A\u533A\u95F4\r
uniform float uTotal; // \u7C92\u5B50\u603B\u6570\r
uniform vec3 uColor; //fs\u91CC\u4F1A\u7528\u5230\r
`,dt=`/**\r
 * \u98DE\u7EBF\u7247\u5143\u7740\u8272\u5668\r
 * @remark \u8BE5\u7740\u8272\u5668\u9700\u8981\u4E00\u4E2Auniform\uFF0C\r
 *         u_color\u81EA\u5B9A\u4E49\u989C\u8272\r
 */

something else i need to do?
thanks for ur help!

@UstymUkhman UstymUkhman self-assigned this Aug 2, 2023
@UstymUkhman
Copy link
Owner

Hi @boythl! Hmm.., this shouldn't be the case since comments are always removed even during the development and compress: true is not required for this purpose. I made a quick test with shaders within this repo and cannot reproduce this issue yet.

/test/glsl/main.frag:

precision highp float;

// First Chunk:
#include /test/glsl/chunk0.frag

out highp vec4 fragColor;

void main (void) {
  fragColor = chunkFn();
}

/test/glsl/utils/chunck2.frag:

/**
 * Red Chunk:
 */

highp float chunkRed () {
  return 0.0;
}

And this is the output JS when building the project:

(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const t of e)if(t.type==="childList")for(const n of t.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&i(n)}).observe(document,{childList:!0,subtree:!0});function l(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?t.credentials="include":e.crossorigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function i(e){if(e.ep)return;e.ep=!0;const t=l(e);fetch(e.href,t)}})();var c="precision highp float;highp float chunkRed(){return 0.0;}highp float chunkGreen(){return 0.8;}highp vec3 chunkRGB(){return vec3(chunkRed(),chunkGreen(),0.0);}highp vec4 chunkFn(){return vec4(chunkRGB(),1.0);}out highp vec4 fragColor;void main(void){fragColor=chunkFn();}";const r=document.getElementById("app");console.info(`Shader Length: ${c.length} characters.`);r.style.backgroundColor="#222222";r.style.fontFamily="monospace";r.style.whiteSpace="pre-wrap";r.style.color="#bbbbbb";r.style.padding="16px";r.textContent=c;
//# sourceMappingURL=index-e08ad4dd.js.map

As you can see, there are no comments in GLSL source code. So I guess I need to ask you to provide a minimal reproducible example with this issue. Thanks!

@UstymUkhman UstymUkhman added needs clarification Waiting for more information question A question about functionality labels Aug 2, 2023
@boythl
Copy link
Author

boythl commented Aug 2, 2023

sorry, it's my fault.
DONOT add ?raw at the end of import, or the glsl file won't be handled.

can i suggest, give a notice in readme about ?raw,
because the homepage of vite suggests that add ?raw when import glsl.

please see here:
https://vitejs.dev/guide/assets.html#importing-asset-as-string

import shaderString from './shader.glsl?raw'

@boythl boythl closed this as completed Aug 2, 2023
@UstymUkhman
Copy link
Owner

Yep, you're might be right, it's worth mentioning in Readme of this repo. Will add to my TODO list, thanks!

@UstymUkhman UstymUkhman added not an issue Something that doesn't need to be fixed and removed needs clarification Waiting for more information question A question about functionality labels Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not an issue Something that doesn't need to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants