E
E
egyptForce2019-04-23 14:18:30
Vue.js
egyptForce, 2019-04-23 14:18:30

How to generate css class name?

I use vue-cli. I use named css modules:

<template>
  <div>
    <div v-if="isTrue()" :class="$foo.container">...</div>
    <div v-else :class="$bar.container">...</div>
  </div>
</template>
<style lang="postcss" module="$foo">
  .container {
    color: green
  }
</style>
<style lang="postcss" module="$bar">
  .container {
    color: red
  }
</style>

Loader settings:
localIdentName: '[hash]_[local]'
As a result, class names are generated the same and redefined. and as a consequence, when v-if is true, the text becomes red, which should be green.
The question is: is it possible to somehow tell the loader to substitute the name of the module in the generated class name, ala:
localIdentName: '[hash]_[local]_[module]'and the output turned out to be something like:
.432j4h2kj4_container_$foo {}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2019-04-23
@egyptForce

https://github.com/webpack-contrib/css-loader#getl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question