I am trying to assign NODE_ENV
to production using webpack3, and have tried the following code:
environment.plugins.append(
'DefinePlugin',
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
)
also tried:
environment.plugins.append(
'DefinePlugin',
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
)
In my component, I have the following:
document.myenv = process.env
console.log(`Running process.env.NODE_ENV: ${process.env.NODE_ENV}`)
If I inspect document.myEnv
in the Chrome developer console, I see NODE_ENV: production
. However, the console.log statement shows Running process.env.NODE_ENV: development
and Vue appears to be behaving in development mode.
How can I fix this so Vue runs in production mode? If it makes a difference, we dynamically create new Vue
in a few places.