veslx 0.1.39 → 0.1.40

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.
@@ -1,4 +1,4 @@
1
- const version = "0.1.39";
1
+ const version = "0.1.40";
2
2
  const packageJson = {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -344,26 +344,36 @@ export default function contentPlugin(contentDir: string, config?: VeslxConfig,
344
344
  }
345
345
  },
346
346
 
347
- // Transform CSS to inject @source directive for Tailwind
348
- // This enables Tailwind v4 to scan the user's content directory for classes
349
- transform(code, id) {
350
- if (id.endsWith('/src/index.css') && code.includes("@import 'tailwindcss'")) {
351
- // Use absolute path with glob pattern for @source directive
352
- // Must include all file types that may contain Tailwind classes
353
- const absoluteContentDir = dir.replace(/\\/g, '/')
354
- const sourceDirective = `@source "${absoluteContentDir}/**/*.{html,js,jsx,ts,tsx,mdx,md,vue,svelte}";`
355
-
356
- // Inject @source directive after the tailwindcss import
357
- const modified = code.replace(
358
- /(@import\s+["']tailwindcss["'];?)/,
359
- `$1\n${sourceDirective}`
360
- )
361
-
362
- return { code: modified, map: null }
347
+ load(id) {
348
+ // Inject @source directive into index.css for Tailwind v4 content scanning
349
+ // This must happen in load() before Tailwind processes the CSS
350
+ if (id.endsWith('/src/index.css')) {
351
+ const veslxRoot = path.dirname(path.dirname(__dirname))
352
+ const cssPath = path.join(veslxRoot, 'src/index.css')
353
+
354
+ try {
355
+ const code = fs.readFileSync(cssPath, 'utf-8')
356
+
357
+ // Check if this CSS file has the tailwindcss import
358
+ if (/\@import\s+["']tailwindcss["']/.test(code)) {
359
+ // Use absolute path with glob pattern for @source directive
360
+ // Must include all file types that may contain Tailwind classes
361
+ const absoluteContentDir = dir.replace(/\\/g, '/')
362
+ const sourceDirective = `@source "${absoluteContentDir}/**/*.{html,js,jsx,ts,tsx,mdx,md,vue,svelte}";`
363
+
364
+ // Inject @source directive after the tailwindcss import
365
+ const modified = code.replace(
366
+ /(@import\s+["']tailwindcss["'];?)/,
367
+ `$1\n${sourceDirective}`
368
+ )
369
+
370
+ return modified
371
+ }
372
+ } catch {
373
+ // Fall through to default loading
374
+ }
363
375
  }
364
- },
365
376
 
366
- load(id) {
367
377
  // Virtual module for content
368
378
  if (id === RESOLVED_VIRTUAL_MODULE_ID) {
369
379
  // Extract frontmatter from MDX files at build time (avoids MDX hook issues)