尝试在 vite/rollup 中为 css 模块创建一种方法,以输出哈希类名和没有

Trying to create a way in vite/rollup for css modules to output a hashed classname and a public class with no

提问人:John williams 提问时间:11/1/2023 更新时间:11/1/2023 访问量:33

问:

尝试为 css 模块创建一种方法来输出散列类名和公共类名(无散列)。

所以

<MyComponent className={styles.myComponent}>
   <Child className={styles.child} />
</MyComponent>

将输出

<div class="__my_component___oCk6T my-component">
  <div class="__my_component__child___oYX6P my-component__child"></div>
</div>

这背后的原因是,在我的库中,我们可以使用CSS模块,我们应该如何生成公开的类名供外部使用。这样有人就可以拉入库,在样式设置时不受限制。

目前,我正在努力寻找一种在我的 vite 配置中配置它的方法。猜我需要为此构建一个自定义插件。

任何帮助都是值得赞赏的。

reactjs vite rollup lib css-modules

评论


答: 暂无答案