Skip to content

Commit dc9fc08

Browse files
committed
support for relative imports in tailwind
1 parent 9c6819e commit dc9fc08

File tree

5 files changed

+318
-4
lines changed

5 files changed

+318
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
99
## [3.0.11] - Unreleased
1010
### Fixed
1111
- `tailwind` plugin: Support to import styles from npm. (i.e. `npm:npm:tw-animate-css`)
12+
- `tailwind` plugin: Imports with relative paths don't work.
1213

1314
## [3.0.10] - 2025-09-24
1415
### Added

plugins/tailwindcss.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export function tailwindCSS(userOptions?: Options) {
7070
site,
7171
file,
7272
);
73-
7473
const compiler = await compile(content, {
7574
from: filename,
7675
async loadModule(id, base, resourceHint) {
@@ -122,6 +121,11 @@ export function tailwindCSS(userOptions?: Options) {
122121
return { content, path: id, base };
123122
}
124123

124+
// If the path is relative, and no base is provided, use the CSS file location as base
125+
if (!base && id.startsWith(".")) {
126+
base = dirname(filename);
127+
}
128+
125129
const path = resolveInclude(id, options.includes || "", base);
126130
const content = await site.getContent(path, false);
127131

tests/__snapshots__/tailwindcss.test.ts.snap

Lines changed: 307 additions & 3 deletions
Large diffs are not rendered by default.

tests/assets/tailwindcss/other.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
color: blue;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
@import "tailwindcss";
2+
@import "npm:[email protected]";
3+
@import "./other.css";

0 commit comments

Comments
 (0)