M
M
Mike2019-06-06 22:00:21
webpack
Mike, 2019-06-06 22:00:21

Why can't I get the process.env.NODE_ENV environment variable?

In my webpack.config.js I have this:

if (process.env.NODE_ENV === 'development') {
  module.exports.devtool = '#source-map'
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"development"',
        ENDPOINT: '"http://localhost:8000"',
        FOO: "'hello world'"
      }
    })
  ])
}

In vue template:
created() {
        this.$store.dispatch('GET_LEVELS')
        this.$store.dispatch('GET_USERLEVELS')
        console.log(process.env.NODE_ENV, ' <------------NODE_ENV', process.env)
    },

I am getting undefined. How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question