admin管理员组文章数量:1428675
I'm kinda new to Javascript development myself. Lately, I've been working on a web app using React and ExpressJS. Express will deliver the static bundled(using Parcel) files of front-end React page. The code organisation is something like this:
> dist\
> [static files here]
> node_modules \
> src \
> client\
> pontents\
> index.html
> index.js
> server\
> models\
> routes\
> index.js
The build process works fine and I get a perfectly working web app. The problem is that Google Chrome's Source developer tool exposes all of my source code for the client. Exposed source code files
Some googling led me to terms such as blackboxing and obfuscation. But I have a hard time understanding them. Some explanation of them and advice on hiding source files will be helpful. Thanks!
I'm kinda new to Javascript development myself. Lately, I've been working on a web app using React and ExpressJS. Express will deliver the static bundled(using Parcel) files of front-end React page. The code organisation is something like this:
> dist\
> [static files here]
> node_modules \
> src \
> client\
> pontents\
> index.html
> index.js
> server\
> models\
> routes\
> index.js
The build process works fine and I get a perfectly working web app. The problem is that Google Chrome's Source developer tool exposes all of my source code for the client. Exposed source code files
Some googling led me to terms such as blackboxing and obfuscation. But I have a hard time understanding them. Some explanation of them and advice on hiding source files will be helpful. Thanks!
Share Improve this question asked Mar 20, 2019 at 6:06 NandhakishoreNandhakishore 691 silver badge5 bronze badges 3-
You cannot hide any file that's getting loaded on any page. Browser need it to run your website. Obfuscation is making your code harder to read essentially modifying your meaningful variable name like
username
toa
. – josephting Commented Mar 20, 2019 at 6:13 - But this seems to expose all of node_modules! Including the packages' source code! – Nandhakishore Commented Mar 20, 2019 at 6:16
-
Your browser needs the source code of each library in order to run them. If there are third-party libraries that you don't need at runtime, consider putting them under
devDependencies
in yourpackage.json
– Arnaud Christ Commented Mar 20, 2019 at 6:58
6 Answers
Reset to default 3Finally got it. I had to include --no-source-maps in parcel build mand
parcel build ./src/client/index.html --no-source-maps
If you don't set the following option, your react source code (not minimized) will be visible. You need to turn off the GENERATE_SOURCEMAP flag.
in package.json
"scripts": { ... "build": "GENERATE_SOURCEMAP=false react-scripts build", ... }
Basically a web browser need to download your .js files in order to work. You cannot prevent this. However, in the published react project, the js files are minified so you dont need to worry about exposing your source code.
You can blackbox your web app by using a service like HideJS to create an interactive stream of your site, instead of actually piling the code on their end.
The code never reaches their puter, so it's not possible to see it.
Set the below property in .env
GENERATE_SOURCEMAP=false
Rebuild
本文标签: reactjsJavascriptHide source files from chrome consoleStack Overflow
版权声明:本文标题:reactjs - Javascript - Hide source files from chrome console - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745531252a2662070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论