@weerachai06/tw-scanner 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/validator.js +14 -4
  2. package/package.json +1 -1
package/dist/validator.js CHANGED
@@ -22,11 +22,21 @@ export async function loadTailwindContext(cssFile) {
22
22
  const msg = err.message ?? '';
23
23
  const match = msg.match(/Cannot apply unknown utility class [`']?([^\s`']+)[`']?/);
24
24
  if (match) {
25
- throw new Error(`Tailwind could not compile "${path.relative(process.cwd(), abs)}" ` +
26
- `unknown utility used in @apply: "${match[1]}".\n` +
27
- ` Fix: add "@utility ${match[1]} {}" to your CSS entry file to register it as a custom utility.`);
25
+ // Strip all @apply lines from the entry CSS and retry so scanning can continue.
26
+ // Unknown utilities are likely defined via PostCSS plugins or external font systems
27
+ // that @tailwindcss/node's compile() doesn't have access to.
28
+ const strippedCss = css.replace(/^\s*@apply\b[^;]+;/gm, '');
29
+ console.warn(`⚠ Skipping @apply in "${path.relative(process.cwd(), abs)}" — ` +
30
+ `unknown utility: "${match[1]}". ` +
31
+ `Add "@utility ${match[1]} {}" to register it if you want it validated.`);
32
+ result = await compile(strippedCss, {
33
+ base: path.dirname(abs),
34
+ onDependency: () => { },
35
+ });
36
+ }
37
+ else {
38
+ throw err;
28
39
  }
29
- throw err;
30
40
  }
31
41
  compileCache.set(abs, result);
32
42
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weerachai06/tw-scanner",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "AST-based Tailwind v4 class validator for React projects",
5
5
  "type": "module",
6
6
  "bin": {