sorrycc / ama

Ask me anything!

Home Page:https://github.com/sorrycc/ama/issues?q=is%3Aissue+is%3Aclosed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the variable NODE_ENV is used in roadhog

951565664 opened this issue · comments

commented

I set NODE_ENV. ...But its value is always equal to ‘production‘

    "build": "cross-env NODE_ENV=production roadhog build",
    "build:dev": "cross-env NODE_ENV=development roadhog build",

I see the roadhog;s code ,
image

Why the variable NODE_ENV is used in roadhog, the variable NODE_ENV is often used to distinguish the test package and the formal package, if used in the roadhog, it will lead to users can not use NODE_ENV. Maybe you can use a custom variable like ROADHOG_NODE_ENV

It's a convention to set NODE_ENV to production in the build process. Libraries like react, redux will be based on this to remove debugging code for the production environment.

e.g.

If (process.env.NODE_ENV === 'production') {
   Console.log('debug code');
}

After build:

If (false) {
   Console.log('debug code');
}

After uglify:

So, if you want to use environment variables to distinguish the environment, you can pick another name, such as ROADHOG_ENV.