will be helpful for those in need I think you are not understanding how this works. PHP code is executed when the client requests the page on the server side. JS is executed on the client side. There is no PHP interpreter on the web browser. What you could do is putting the PHP code in a separate file (Example: fragment.php) and calling it through AJAX. In that case your code will be executed in the server. I hope this helps!
var a = '"dumb quotes" instead -- of "dumb quotes", fixed it\'s';
a = a.replace(/'\b/g, "\u2018") // Opening singles
.replace(/\b'/g, "\u2019") // Closing singles
.replace(/"\b/g, "\u201c") // Opening doubles
.replace(/\b"/g, "\u201d") // Closing doubles
.replace(/--/g, "\u2014") // em-dashes
.replace(/\b\u2018\b/g, "'"); // And things like "it's" back to normal.
// Note the missing `;` in these lines. I'm chaining the `.replace()` functions.
'“dumb quotes” instead — of “dumb quotes”, fixed it's'
this one helps. This webpack plugin is going to be doing interpolation in your code. In other words, it will be replacing, at build time, process.env.NODE_ENV with whatever you have there. So your code goes from console.log(process.env.NODE_ENV) to console.log("development"). If you left out the single quotes it would become console.log(development), which would fail since there is no variable development.