0

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.

kichik
  • 33,220
  • 7
  • 94
  • 114
Julie
  • 1,941
  • 3
  • 17
  • 30
  • Have you tried just setting `process.env.NODE_ENV = 'production'` without `DefinePlugin`? – kichik Oct 10 '18 at 17:11
  • @tony19 changing all `import Vue from 'vue/dist/vue.esm'` to `import Vue from 'vue/dist/vue.min'` did the trick! Please post as an answer and I will accept. – Julie Oct 10 '18 at 17:50

0 Answers0