There isn't an official or suggested way around it, as far as I know, while I was dealing with this problem. But there are some workarounds. I'm using postcss-preset-env and there's an importFrom option. There you can load a file with variables which are going to be provided for each file, so there's no need to import them manually.
Downside is that you can only import .css, .js or .json. Which is unfortunate if you're using something like SASS, LESS or simply different syntax like SugarSS. So you have to keep variables in different file type than all the others. When it comes to mixins, they don't get injected so I import them per file.
Another possibility is to use one of the deduplication plugins provided.
Last one I can think of is just use postcss-simple-vars, instead of :root and native CSS variables.
Although I was using variables like this plugin supports, I like to use native CSS variables when they're supported, even though I like plugin syntax better.
Hope this helps as bit.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There isn't an official or suggested way around it, as far as I know, while I was dealing with this problem. But there are some workarounds. I'm using postcss-preset-env and there's an importFrom option. There you can load a file with variables which are going to be provided for each file, so there's no need to import them manually.
Downside is that you can only import .css, .js or .json. Which is unfortunate if you're using something like SASS, LESS or simply different syntax like SugarSS. So you have to keep variables in different file type than all the others. When it comes to mixins, they don't get injected so I import them per file.
Another possibility is to use one of the deduplication plugins provided.
Last one I can think of is just use postcss-simple-vars, instead of :root and native CSS variables.
Although I was using variables like this plugin supports, I like to use native CSS variables when they're supported, even though I like plugin syntax better.
Hope this helps as bit.