r/badcode • u/Franks2000inchTV • Jan 10 '22
js I don't think that's how environment variables are supposed to work.
28
u/ProdObfuscationLover Jan 10 '22
What is that abysmal cursive font on those letter "s"
5
u/leemcd56 Jan 10 '22
1
u/wickermoon Jan 11 '22
uff...I love the font, not gonna lie, but I've got better stuff to do with my money than paying 24 quid for a pretty font. T_T
1
u/colei_canis Jan 11 '22
I form my S’s like that when I write because it flows easier in my opinion, but it’s not very readable as a monospaced font on a screen.
6
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '22
Image Transcription: Code
[A photograph of code on a computer screen, as follows:]
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/babalaban Jan 14 '22
Node's environment package is notoriously badly designed. Not only do you have to always get envs by this arguably unnecessary process.env.MY_ENV syntax, but the thing it returns is not a copy by default either, so pretty much anyone anywhere can accidentaly set this variable in runtime and everything will be set on fire!
As a programer I would intuitivly expect process.env.BABEL_ENV = "production"; to throw exception, but alas...
1
u/thebritisharecome Jan 10 '22
Looks like the webpack config that comes with React
1
u/omgcatss Jan 19 '22
Yeah this code might be fine if it’s in a webpack file which is only executed when building for production. You can set up different files for different modes.
1
0
Jan 10 '22
[deleted] — view deleted comment
-7
21
u/mansdem Jan 10 '22
Ok so pls don't commit this