Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why JSON.stringify('production')?

Tags:

webpack

In the Webpack Production Documentation, one recommendation is to instantiate the object with a configuration variable for process.env.NODE_ENV, with the following recommended code:

+     new webpack.DefinePlugin({
+       'process.env.NODE_ENV': JSON.stringify('production')
+     })

Why JSON.stringify('production') and not just merely 'production'?

like image 522
zsteinkamp Avatar asked May 21 '18 18:05

zsteinkamp


Video Answer


1 Answers

Found the answer elsewhere in the webpack docs.

According to the define-plugin docs, you must supply a string with quotes embedded.

T> Note that because the plugin does a direct text replacement, the value given to it must include actual quotes inside of the string itself. Typically, this is done either with either alternate quotes, such as '"production"', or by using JSON.stringify('production').

Thanks TheIncorrigible1 for the Monday banter.

like image 167
zsteinkamp Avatar answered Sep 22 '22 23:09

zsteinkamp