question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update vue-cli mode documentation to show a mode other than production or development

See original GitHub issue

What problem does this feature solve?

Increases comprehension on what the --mode feature can be used for and how it might be used, specifically that you can override the NODE_ENV variable to produce a production build with alternate config (ie. staging)

Refer to https://forum.vuejs.org/t/how-to-build-production-app-with-varying-config/29708/3

What does the proposed API look like?

.env
VUE_APP_TITLE=My App
.env.staging
NODE_ENV=production
VUE_APP_TITLE=My App (staging)
vue-cli-service build
  • builds a production app using .env then .env.production (or .env.production.local)
vue-cli-service build --mode staging
  • builds a production app using .env then .env.staging (or .env.staging.local)

In both cases, the app is built as a production app because of the NODE_ENV, but in the staging equivalent the process.env.VUE_APP_TITLE variable is overrided

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
richard-edwardscommented, Mar 24, 2018

@jnarowski See the start of this thread, just add a ‘.env.staging’ file and add the NODE_ENV=production as the first line and then do vue-cli-service build --mode staging

1reaction
chriszrccommented, Dec 21, 2018

Hmm, I’m wondering if the example of setting the BASE_URL on this page should also be updated:

https://cli.vuejs.org/config/#baseurl

Because if the only way to trigger a slimmed down “production” build is by setting the NODE_ENV=production, it makes relying on the NODE_ENV to inform the app about which environment you’re in useless.

Instead, it seems like the example here should instead rely on using the modes, and setting the different base_urls in an environment variable in the corresponding .env.[mode] file and using that variable to set the baseUrl: value:

baseUrl: process.env.BASE_URL_PREFIX,
Read more comments on GitHub >

github_iconTop Results From Across the Web

Modes and Environment Variables - Vue CLI
Mode is an important concept in Vue CLI projects. ... will determine the primary mode your app is running in - development, production...
Read more >
Custom Build Modes with Vue CLI 3 | Rangle.io
In this post, we'll go over how to add and configure a custom build mode other than the default production, development and test...
Read more >
Using Environment Variables with Vue.js - Stack Overflow
Vue.js with Webpack. If you use vue cli with the Webpack template (default config), you can create and add your environment variables to...
Read more >
Building with custom mode will lose all built-in config. #4699
"buildtest": "vue-cli-service build --mode test" ... set NODE_ENV to other values than the commonly used production , development and test .
Read more >
How To Use Environment Variables in Vue.js - DigitalOcean
With Vue.js, it is possible to use environment variables through files with the .env file extension. These files are responsible for storing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found