0

We can set custom modes in cli 3.

Because it is not a production mode, it would not be a optimized build.

How do I set config to custom mode to reach the optimized build as production mode.

custom mode(staging) in package.json

The files of default production mode(optimized), command: npm run build

The files of custom mode(staging) (not optimized), command: npm run staging

Thanks in advance.

Abner Wang
  • 23
  • 6

1 Answers1

1

I think you are Mixing between two things first vue build app.vue command builds a production ready bundle.

Modes are just another name for environment, which specifies if you’re in development, production or test mode.

if you want to associate different mode with your build you can append it like that vue-cli-service build --mode development. by --mode you assign what environment variables you need with that build.

if you want the stage build to be optimized as production just put NODE_ENV=production in the start of your .env.staging file .

ref: CLI docs modes and env in cli docs

  • [Abaner](https://stackoverflow.com/users/9823362/abner-wang) did that make any sense to you if so can you please accept the answer and Upvote it – Ahmed Magdy Sep 15 '18 at 08:56
  • Thank you for your answer, but the key point is the results between default production mode and custom mode, I would edit my question to show the differences. – Abner Wang Sep 16 '18 at 03:42
  • Dear don't know if you are still interested i found the solution is to put NODE_ENV=production in the start of your .env.staging file . ref : https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode – Ahmed Magdy Nov 26 '18 at 11:00
  • 1
    @AhmedMagdy thanks for ```NODE_ENV=production```, it worked for me – YugoAmaryl Nov 20 '19 at 08:12
  • @AbnerWang Hey I think I have answered your question can Accept the answer. – Ahmed Magdy Jul 15 '20 at 13:05