Vue staging build creates a development build instead of production

Viewed 920

Vue documentation:

vue-cli-service build --mode staging builds a production app in staging mode, using .env, .env.staging and .env.staging.local if they are present.

package.json

"buildStaging": "vue-cli-service build --mode staging",

.env.staging

VUE_APP_LOG_PRODUCTION_TIP=true

Then

>npm run buildStaging
> between-us-drivers@0.1.0 buildStaging C:\dev\mezinamiridici\spa
> vue-cli-service build --mode staging
/  Building for staging...

And the result is:

171 650 admin-chunk.js
112 650 admin-chunk.js.map
6 156 774 app.js
6 008 903 app.js.map
1 517 776 content-chunk.js
1 434 561 content-chunk.js.map
477 276 user-chunk.js
425 751 user-chunk.js.map

Why is there the development build instead of production build?

1 Answers

If you want your staging to make a production build you'll need to specify it via NODE_ENV in .env.staging:

NODE_ENV=production
VUE_APP_LOG_PRODUCTION_TIP=true

This is hinted at, but not highlighted in the documentation example for staging:

The app is built as a production app because of the NODE_ENV, but in the staging version, process.env.VUE_APP_TITLE is overwritten with a different value

The core behavior is covered slightly earlier in the documentation:

When running vue-cli-service, [...] NODE_ENV will be set to "production" in production mode, "test" in test mode, and defaults to "development" otherwise.

Related