Home

Issue: 1456

Access the mode property from inside a plugin?

[issue link]

Is this possible? I’d like to check if the build is running in spa mode inside /plugins/.

And also, would it make a difference if mode is set via nuxt.config.js or via cli argument?

// nuxt.config.js

module.exports = {
  mode: 'spa' // or 'universal'
}

vs

// package.json
...

"scripts" : {
   "build" : "nuxt build --spa"
}

...

And then in a plugin (ie: /plugins/my-plugin.js

// my-plugin.js

// not working, but example
const mode = options.mode  // 'spa' or 'universal'

This feature request is available on Nuxt.js community (#c1296)