Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class names with square brackets and escaped characters #133

Closed
da-yauhenzadziarkouski opened this issue Jun 25, 2021 · 2 comments · Fixed by #135
Closed

Class names with square brackets and escaped characters #133

da-yauhenzadziarkouski opened this issue Jun 25, 2021 · 2 comments · Fixed by #135
Labels

Comments

@da-yauhenzadziarkouski
Copy link

da-yauhenzadziarkouski commented Jun 25, 2021

The code

const files = {
    css: fg.sync("_site/**/*.css"),
    js: fg.sync("_site/**/*.js"),
    html: fg.sync("_site/**/*.html"),
}

files.css.forEach((filePath) => rcs.fillLibraries(fs.readFileSync(filePath, "utf8")))

rcs.optimize()

Object.keys(files).forEach((key) => {
    files[key].forEach((filePath) => {
        const content = rcs.replace[key](fs.readFileSync(filePath, "utf8"))
        fs.writeFileSync(filePath, content)
    })
})

The problem
I use TailwindCSS with rcs-core. There is an ability to define a css property value between square brackets, but rcs.replace works incorrectly.

Example

CSS:
.bottom-\[99999px\] {bottom: 99999px;}

HTML:
<div class="bottom-[99999px]"></div>

Expected:

CSS:
.a {bottom: 99999px;}

HTML:
<div class="a"></div>

Actual result:

CSS:
.a[99999px] {bottom: 99999px;} /* also, it's broken, because backslashes were removed */

HTML:
<div class="bottom-[99999px]"></div>


I've also tried to exclude, but that didn't work either. Example:

rcs.selectorsLibrary.setExclude(/[A-z0-9-[.#]*]/g)
console.log("is excluded: bottom-[123px]", rcs.selectorsLibrary.isExcluded("bottom-[123px]")) // is excluded: bottom-[123px] true
console.log("is excluded: leading-none", rcs.selectorsLibrary.isExcluded("leading-none") // is excluded: leading-none false
@JPeer264
Copy link
Owner

Hey @da-yauhenzadziarkouski thanks for your detailed issue. I'm going to investigate ASAP.

@JPeer264
Copy link
Owner

@da-yauhenzadziarkouski should work in v3.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants