Skip to content

Commit b3a981d

Browse files
committed
add support for esm tailwind config
1 parent 2bad85a commit b3a981d

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/Breakpoints/Breakpoints.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ private function getFromTailwind(): self
4747

4848
$files = [
4949
'tailwind.config.js',
50+
'tailwind.config.ts',
5051
'tailwind.config.theme.js',
5152
'tailwind.config.site.js',
5253
];

src/Breakpoints/Parser/TailwindParser.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ private function parseConfigFile($filename): void
6464

6565
$source = file_get_contents(base_path($filename));
6666

67-
$ast = Peast::latest($source)->parse();
67+
$ast = Peast::latest($source, [
68+
'sourceType' => Peast::SOURCE_TYPE_MODULE,
69+
])->parse();
6870

6971
// search for 'screens' config
7072
$query = $ast->query("Property[key.name='screens']");

tests/Feature/TailwindBreakpointsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@
6666
'2xl' => 'min-width: 1536px',
6767
]);
6868
});
69+
70+
it('returns user values when using an esm config', function () {
71+
copy(__DIR__ . '/../stubs/tailwindcss/esmConfig.stub.js', $this->config);
72+
73+
expect($this->parser->parse())->toBe([
74+
'test' => 'min-width: 123px',
75+
'test-max' => 'max-width: 456px',
76+
]);
77+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import('tailwindcss').Config} */
2+
export default {
3+
content: [],
4+
theme: {
5+
extend: {
6+
colors: {
7+
hotPink: '#FF269E',
8+
},
9+
},
10+
screens: {
11+
test: '123px',
12+
'test-max': { 'max': '456px' },
13+
},
14+
},
15+
plugins: [],
16+
}

0 commit comments

Comments
 (0)