Target to a custom Mode in Vue CLI
â˘
1 min read
Just a reminder and a TIL about customize the development setup of a Vue app with the CLI.
If you need to create a new custom Mode (other than âstagingâ, âtestâ and âproductionâ), here the tip:
- create a new
.env.mymodefile (where.mymodeis the name of your mode) - write in it
NODE_ENV=mymode - add in
package.jsona new run in âscriptsâ likevue-cli-service serve --mode mymode - Run it with the new command name (such as
npm run mymode) - Use anywhere in your code both the injected env variables as well as the
process.envvariable such as:
if (process.env.NODE_ENV === 'mymode') {
console.log("another mode!")
}
Tip mainly from here.