Prod vs Dev mode - uglifyjs turned off
-
Dear Devs,
I noticed that when I run the forum on dev mode, the client files are packed together and uglified. However, when I use prod mode, the code does not get uglified.
I'd like to have the code uglified, so should I work in dev mode?
I notice a warning in the admin page saying "Forum is running in development mode. The forum may be open to potential vulnerabilities; please contact your system admin.", so I am a bit worried.Most likely I am running the forum incorrectly, and making an ass of myself.
But just in case the above is the intended behavior, how should i turn on production mode and pack/uglify the client code?
Thank you!
JJ. -
If you run
./nodebb build
it should minify all of the bundled assets. How are you checking whether it's minifying, etc? -
Hi @PitaJ
Thanks for responding!
I am running ./nodebb build, but it does not minify and uglifies the code.
To see the client code, you may open "inspect" in chrom and upload any js file you wish - the source map are generated and are provided for all eyes to seeKindly note that your forum exhibit the very same issue - just open inspect on chrome and then ALT-P and open "client.js" for example. Its open. There must be a reason for that I am sure, but in my specific case, I'd love to have my code uglified and packed.
I also use grunt. Grunt does uglifies the code, but only in dev mode.
Any thoughts?
Thanks!!!
JJ -
I was correct in thinking you were confused. The files you're seeing in the developer tools are the source-mapped files. You aren't seeing the actual files as they're served to your browser.
For instance, compare the
translator.js
you see in the developer tools on this site to the file at /assets/src/modules/translator.js. I can actually see the minifiednodebb.min.js
in the developer tools just fine, and it matches with what I see at /assets/nodebb.min.js.The reason this occurs is because we don't produce the source-map for
nodebb.min.js
when in dev mode, as the file isn't minified in that mode, just concatenated from the source files. -
You can delete all of the
.map
files in the build directory:rm ./build/**/*.map
-
Grunt doesn't handle production builds. It's only for development. Without editing nodebb files there's isn't a way to disable creating the files, or to remove them after automatically.
However, you could make them appear as empty files or 404s through your reverse proxy.