Matthias Dunkel
Matthias Dunkel

Reputation: 305

How to build for staging with cache busting

I have a .env.staging file with some configs for when I'm building my Vue app for staging.

But if I build now with vue-cli-service build --mode staging it will not append a hash to the output files, thus there is no cache busting. (Which is does when there is no "mode")

Is there a way of using the env-file, and still have cache busting?

Upvotes: 0

Views: 815

Answers (1)

Ed Martin
Ed Martin

Reputation: 116

The way I accomplished this was to specify the following in the .env.staging file:

NODE_ENV=production

And then in vue.config.js

let config = {};

if(process.env.NODE_ENV !== 'development'){
     config.filenameHashing = true;
}

module.exports = config;

Upvotes: 1

Related Questions