V
V
vruzin2020-04-22 08:27:34
Vue.js
vruzin, 2020-04-22 08:27:34

How to remove a tag from production?

How to remove the template tag from production???
This means that the template code does not even get into the compilation.

...
<template v-if="process.env.NODE_ENV !== 'production'">
Видно только в разработке
</template>
...


I suppose we need to write something in v-if, but I don’t know what.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2020-04-22
@Fragster

If it is assembled by webpack (for example, from vue cli or quasar), then something like this:

...
        <div v-if="dev">
           dev
        </div >
...

...
  computed: {
    dev() {
      return process.env.DEV;
    }
  },
...

V
vruzin, 2020-04-22
@vruzin

yes, build via vue cli. But alas, it didn't help. It is clear that it is not visible, but this block does not disappear in the final app.js anyway.
You can of course through javascript, but it's inconvenient. I want a simple and effective solution that removes the code from the final assembly...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question