[Vuejs]-How to apply webpack tree shaking feature to Vue template‘s v-if directive?

0👍

As far as I know tree shaking works on script level not on vue template. Maybe you should try to pass client component/module to template?

<template>
  <div :is="clientModule"></div>
</template>
created() {
  if(process.env.VUE_APP_CLIENT === 'A') {
    this.clientModule = moduleClientA
  }
  else {
    this.clientModule = moduleClientB
  }
}

If I’m wrong you need also fix computed property because you use ‘=’ instead of ‘==’.

Leave a comment