Created
April 9, 2024 15:19
-
-
Save msyfls123/12f3cdd1827ea4649cbb565f866d329c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://regex101.com/r/30Xvde/1 | |
const fs = require('fs') | |
const VAR_REG = /(?:@extend\s.\\@|&:extend\(\.\\@|@extend\s.\\\$)([^\;\r\n\t\s\)]+)/gm; | |
const sassInput = fs.readFileSync('style/style.scss', 'utf-8'); | |
const lessInput = fs.readFileSync('style/style.less', 'utf-8'); | |
const stylusInput = fs.readFileSync('style/style.styl', 'utf-8'); | |
function getVariables(input) { | |
return Array.from(input.matchAll(VAR_REG)).map(([, key]) => key); | |
} | |
[sassInput, lessInput, stylusInput].map(getVariables).forEach((v) => console.log(v)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment