How to optimize a string to a constant in an existing project (the string appears multiple times in css, js)

A color value is written in many places in the js/css file of the project, and the color value must be uniform, so when we need to change this color value, we have to change it everywhere. Is there any way to set it uniformly?
Note: we only use traditional css, instead of precompilable css such as scss.

Mar.18,2021

for traditional projects, there is usually a common style file that is imported first. You can set up a class to put colors

.
  
  1. in fact, this is an opportunity to adopt scss. Traditional css does not conflict with the adoption of scss.
  2. performs document replacement output.
Menu