The global variable of webpeack configuration is undefined?

//webpack :
if(env.production) {
    plugins.push(
      new MiniCssExtractPlugin({
        filename: path.posix.join(__dirname, "../dist/style.css")
      }),
      new webpack.DefinePlugin({
        "process.env": {
          NODE_ENV: ""production""
        }
      })
    )
  }
  console.log("="+process.env.NODE_ENV)

Picture description
the value is assigned by DefinePlugin, and the value is displayed as undefined,. I don"t know what happened.

Apr.09,2021

first of all, please read the DefinePlugin documentation carefully.

now I assume you have read it. DefinePlugin is used to replace constants in the code, such as const a = SOME_CONST in the code, and DefinePlugin ({SOME_CONST:'"hello"'}) in your configuration file, then the code will be replaced with const a = "hello" , so quotation marks are very important here.

so you can see how inexplicable it is for you to output the definition directly in the configuration file without looking at the document.

as for how to handle errors, it depends on how you use them in your code. It is recommended that you find the corresponding line and adjust the configuration according to your code.


console.log('='+process.env.NODE_ENV)

the above code is put into your business code

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e561dd-448cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e561dd-448cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?