Vite.js переименовывает имена классов CSS. Как тогда использовать имена классов в селекторах CSS? ⇐ CSS

Разбираемся в CSS
Гость
Vite.js переименовывает имена классов CSS. Как тогда использовать имена классов в селекторах CSS?

Сообщение Гость »


I have this code:

Код: Выделить всё

import styles from "../styles/dragdrop.module.css"; (...) return (               ); 
After building the project with vite, the code looks like this:
(the CSS classname has changed from dragDrop to _dragDrop_d8kak_45).

But I'm using CSS selectors in my front-end JS to do stuff with those divs:

Код: Выделить всё

const targetBox = e.target.closest(".dragDrop"); 
My frontend js doesn't work anymore.

I could perhaps start using css selectors like div[class*="dragDrop"], but it seems like a bad idea.

How is this done properly?


Источник: https://stackoverflow.com/questions/781 ... -selectors

Вернуться в «CSS»