File Scanning Configuration
Obfus-Tail automatically scans your project files to find Tailwind classes for obfuscation. Understanding how the scanning works helps you control exactly which files get processed.
Obfus-Tail automatically scans your project files to find Tailwind classes for obfuscation. Understanding how the scanning works helps you control exactly which files get processed.
The obfuscation script uses a specific configuration to scan your project files. Here's the actual configuration from scripts/obfuscate-tailwind.js:
const CONFIG = {
filesToScan: [
"src/**/*.{jsx,tsx,js,ts,html}",
"pages/**/*.{jsx,tsx}",
"components/**/*.{jsx,tsx}",
"app/**/*.{jsx,tsx}",
],
excludePatterns: ["node_modules", ".next", "dist", ".git"],
outputCssPath: "app/obfuscated-styles.css",
mapFilePath: ".obfuscation-map.json",
randomNameLength: 8,
};
The script uses the glob package to find files matching the patterns in filesToScan while excluding anything matching excludePatterns.
// For each pattern in CONFIG.filesToScan
const files = await glob(pattern, {
ignore: CONFIG.excludePatterns,
windowsPathsNoEscape: true,
dot: true,
});
The script searches for className and class attributes in your files:
const TAILWIND_CLASS_REGEX =
/\bclassName\s*=\s*(["'`])((?:\\.|(?!\1)[\s\S])*)\1/g;
const CLASS_ATTR_REGEX = /\bclass\s*=\s*(["'`])((?:\\.|(?!\1)[\s\S])*)\1/g;
To customize which files get scanned, modify the CONFIG object in scripts/obfuscate-tailwind.js:
const CONFIG = {
filesToScan: [
"src/**/*.{jsx,tsx,js,ts,html}",
"pages/**/*.{jsx,tsx}",
"components/**/*.{jsx,tsx}",
"app/**/*.{jsx,tsx}",
// Add your custom patterns here
"lib/**/*.{ts,js}",
"hooks/**/*.{ts,js}",
],
excludePatterns: ["node_modules", ".next", "dist", ".git"],
// ... rest of config
};
const CONFIG = {
filesToScan: [
"app/**/*.{tsx,jsx}", // App router pages and layouts
"components/**/*.{tsx,jsx}", // Shared components
],
excludePatterns: [
"node_modules",
".next",
"dist",
".git",
"app/api/**", // Exclude API routes
],
};
const CONFIG = {
filesToScan: [
"src/**/*.{tsx,jsx,ts,js}",
"stories/**/*.{tsx,jsx}", // Storybook stories
],
excludePatterns: [
"node_modules",
".next",
"dist",
".git",
"src/**/*.test.*",
"src/**/*.stories.*",
],
};