<dependency>
<groupId>org.postcss</groupId>
<artifactId>postcss</artifactId>
<version>8.0.16</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.versions</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.13.0</version>
</dependency>
import org.postcss.CssNode;
import org.postcss.PresetEnv;
import org.postcss.RebaseRule;
import org.postcss.Ruleset;
import org.postcss.Selector;
import java.io.IOException;
public class PostCSSProcessor {
public static void main(String[] args) throws IOException {
String cssContent = readFile("src/main/resources/styles.css");
PostCSS postCSS = new PostCSS();
postCSS.use(PresetEnv());
CssNode root = postCSS.parse(cssContent);
root.walk((node) -> {
if (node instanceof RebaseRule) {
System.out.println("Rebase rule found.");
}
});
writeToFile("src/main/resources/output.css", root.toSource());
}
private static void readFile(String filePath) throws IOException {
byte[] content = Files.readAllBytes(Paths.get(filePath));
String content = new String(content, StandardCharsets.UTF_8);
return content;
}
private static void writeToFile(String filePath, String content) throws IOException {
Files.write(Paths.get(filePath), content.getBytes(StandardCharsets.UTF_8));
}
}