[Vuejs]-Vue.js : "Invalid or unexpected token" when using webpack.DefinePlugin()

6👍

From DefinePlugin docs:

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').

So, change your code to:

new webpack.DefinePlugin({
  'process.env': {
    loginEmail: "'xxxxx'",
    loginPw: "'xxxxxx'"
  }
})

or

new webpack.DefinePlugin({
  'process.env': {
    loginEmail: JSON.stringify("xxxxx"),
    loginPw: JSON.stringify("xxxxxx")
  }
})

Leave a comment