Skip to content

Commit fac57af

Browse files
authored
Merge pull request #28 from n4j1Br4ch1D/dev
Dev
2 parents e17f0f3 + a9071b7 commit fac57af

File tree

15 files changed

+323
-127
lines changed

15 files changed

+323
-127
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
/coverage
1010

1111
# production
12-
test/demo/build
13-
test/demo/out
14-
test/demo/css-obfuscator
15-
test/demo/src/css/output.css
12+
test/**/build
13+
test/**/out
14+
test/**/css-obfuscator
15+
test/**/src/css/output.css
1616

1717
# misc
1818
.DS_Store

README.md

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,3 @@
1-
<table><tr><td>
2-
3-
👋 Hello everyone,
4-
5-
I've recently started working on Version 2 of postcss-obfuscator 🚀.
6-
7-
First and foremost, I must apologize 🙏 for my absence. I've been incredibly busy due to some life complications 😔.
8-
9-
The upcoming update aims to enhance the plugin and address all outstanding issues 📌.
10-
11-
I will also revisit previously closed inquiries that received unsatisfactory responses 😀.
12-
13-
Being absent has, in a way, been beneficial, as it allowed me to gather more insights about its usage, bugs, etc 🔭.
14-
15-
A huge thank you to <a href="https://github.com/soranoo">@soranoo</a>, <a href="https://github.com/hoangnhan2ka3">@hoangnhan2ka3</a>, and all the others for their excellent work on <a href="https://github.com/soranoo/next-css-obfuscator">next-css-obfuscator</a> 👏.
16-
17-
I manage this project during my limited time over the weekends ⏳.
18-
19-
Therefore, I am seeking sponsorship 🤝 to support my efforts in making this plugin stable🛡️.
20-
21-
&nbsp;&nbsp;&nbsp;[![Sponsor Me](https://img.shields.io/static/v1?label=Sponsor-Me&message=❤️&style=social)](https://www.paypal.com/paypalme/NajibRachid01)
22-
23-
<details>
24-
<summary>Here is the current agenda 📅: Click me</summary>
25-
26-
```
27-
## Goals:
28-
- [ ] Resolve all open issues & closed unsatsfied Isssues.
29-
- [ ] No breaking changes.
30-
- [ ] Test With Many Stack as possible.
31-
- [ ] Better Experince & Features.
32-
## HotFix:
33-
- [ ] Advanced CSS Parser. issues: #3, #5, #6, #11, #12, #13, #14, #18, https://github.com/soranoo/next-css-obfuscator/issues/9, https://github.com/soranoo/next-css-obfuscator/issues/23
34-
- [ ] Accurate Replacer. issues: #9, #10, #20, #24 #octal , https://github.com/soranoo/next-css-obfuscator/issues/4, https://github.com/soranoo/next-css-obfuscator/issues/25, https://github.com/soranoo/next-css-obfuscator/issues/24
35-
- [ ] Fix, Improve Stacks:
36-
- [ ] Use with Astro + Tailwind ? #1
37-
- [ ] Use with Vite + React + Tailwind ? #2 #22
38-
- [ ] Use with Gulp-postcss ? #4
39-
- [ ] Use with Laravel-Mix (outside Laravel) ? #8
40-
- [ ] How to use with Next.js? #15
41-
- [ ] Use with Nuxt2/Nuxt3 ? #16
42-
- [ ] Use with SvelteKit + Tailwind? #17 #21
43-
- [ ] Need Help Integrating with Techstack: Laravel, InertiaJS (SSR), and React #23
44-
## Bugs:
45-
- [ ] Duplicated randoms!.
46-
- [ ] Accurate classes Count.
47-
- [ ] Fresh option breaking.
48-
- [ ] Skip prefix/suffix for ignored classes
49-
## Features
50-
- [ ] Compare size before & after.
51-
- [ ] Advanced Tailwindcss Classes.
52-
- [ ] Support js variables: bg-[url(${card.img})]
53-
- [ ] ClassIgnore to support regular expression(antdesign): #19
54-
- [ ] New option shorten(https://github.com/n4j1Br4ch1D/postcss-obfuscator/issues/1#issuecomment-1656538410).
55-
- [ ] New classMethod: "escaped"
56-
- [ ] New classMethod: 'count'.
57-
- [ ] Testing feature.
58-
- [ ] Multi srcPath.
59-
- [ ] Multi desPath.
60-
- [ ] Draft for orderJson option.
61-
- [ ] Internal Css support.
62-
- [ ] Auto Obsfuctaion. setup to genarte classes every time a server is hit.
63-
- [ ] CDN caches while deployment.
64-
## Tests:
65-
- [ ] classFinder.
66-
- [ ] cssReplacer.
67-
- [ ] RandomsGenerator.
68-
- [ ] RandomsReplacer.
69-
## Docs:
70-
- [ ] Better Readme.
71-
- [ ] Add Sponsors Table.
72-
- [ ] Wiki usage cases: diffrent stacks, solutions and sourcecodes.
73-
- [ ] Minimal config.
74-
```
75-
</details>
76-
Your demands, suggestions, and contributions are always welcome 😇.
77-
78-
💻 Check progres on [dev branch](https://github.com/n4j1Br4ch1D/postcss-obfuscator/tree/dev).
79-
</td>
80-
<td>
81-
✉️
82-
</td>
83-
</tr></table>
841
<sub>
852
<a href="#Intro" title="Section Intro" style="font-size:smaller;">Intro</a>➤<a href="#Motivation" title="Section Motivation">Motivation</a>➤<a href="#Features" title="Section Features">Features</a>➤<a href="#Installation" title="Section Installation">Installation</a>➤<a href="#Usage" title="Section Usage">Usage</a>➤<a href="#Configuration" title="Section Configuration">Configuration</a>➤<a href="#FAQ" title="Section FAQ">FAQ</a>➤<a href="#Releases" title="Section Releases">Releases</a>➤<a href="#Contributing" title="Section Contributing">Contributing</a>➤<a href="#License" title="Section License">License</a>➤<a href="#Check-Also" title="Section Check Also">Check Also</a>
863
</sub>

index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const {
1010
logger,
1111
getRelativePath,
1212
isFileOrInDirectory,
13+
escapeClassName,
14+
octalizeClassName,
1315
} = require("./utils");
1416
const path = require("path");
1517

@@ -172,15 +174,25 @@ module.exports = (options = {}) => {
172174
newClassName = getRandomName(length);
173175
}
174176
newClassName = `.${classPrefix}${newClassName}${classSuffix}`;
175-
177+
validCssClassName = '.'+escapeClassName(oldClassName.slice(1));
178+
//cond
179+
octalValidCssClassName = '.'+octalizeClassName(oldClassName.slice(1));
176180
// If ClassName already exist replace with its value else generate new : the should have same name.
181+
console.log("validCssClassName:", validCssClassName);
177182
if (jsonData.hasOwnProperty(oldClassName)) {
178183
selector = selector.replace(
179-
oldClassName,
184+
validCssClassName,
185+
jsonData[oldClassName]
186+
);
187+
//cond
188+
selector = selector.replace(
189+
octalValidCssClassName,
180190
jsonData[oldClassName]
181191
);
182192
} else {
183-
selector = selector.replace(oldClassName, newClassName);
193+
selector = selector.replace(validCssClassName, newClassName);
194+
//cond
195+
selector = selector.replace(octalValidCssClassName, newClassName);
184196
jsonData[oldClassName] = newClassName;
185197
}
186198
singleFileData[oldClassName] = newClassName;

package-lock.json

Lines changed: 13 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
},
5555
"homepage": "https://github.com/n4j1Br4ch1D/postcss-obfuscator#readme",
5656
"devDependencies": {
57-
"postcss": "^8.4.23",
57+
"css-selector-parser": "^3.0.4",
58+
"postcss": "^8.4.35",
5859
"postcss-cli": "^10.1.0",
5960
"tailwindcss": "^3.2.7"
6061
}

0 commit comments

Comments
 (0)