search

Home  >  Q&A  >  body text

node.js - Based on dvajs, how can I get the current environment in the code?

How can I get the current environment in the code? For example, when I develop, I want to simulate the results of user input...such as the results of scanning a QR code...

I read a few webpack configuration files and it said that node_env can be obtained. But no matter how I configure it, it has no effect...

if(ENV=='dev'){
console.log('开发环境');
}
else{
console.log('生产环境');
}

thank you all.

天蓬老师天蓬老师2800 days ago486

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-16 13:41:23

    webpack has a plug-in

    new webpack.DefinePlugin({
                'ENV': '"production"'
            })

    reply
    0
  • Cancelreply