@poveste/plugin-tailwind 0.6.0
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.
- package/README.md +28 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +721 -0
- package/package.json +45 -0
- package/src/index.spec.ts +41 -0
- package/src/index.ts +765 -0
- package/tsconfig.json +40 -0
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@poveste/plugin-tailwind",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"description": "Poveste plugin that renders a Tailwind design system as a story",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Sorin Gitlan"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"url": "https://github.com/poveste-dev/poveste.git",
|
|
12
|
+
"type": "git",
|
|
13
|
+
"directory": "packages/poveste-plugin-tailwind"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/index.js",
|
|
20
|
+
"./*": "./*"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "rimraf dist && tsc -d",
|
|
27
|
+
"watch": "tsc -d -w --sourceMap",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:dev": "vitest"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"poveste": "workspace:^"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@poveste/shared": "workspace:*",
|
|
36
|
+
"pathe": "^1.1.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.10.1",
|
|
40
|
+
"poveste": "workspace:*",
|
|
41
|
+
"typescript": "catalog:",
|
|
42
|
+
"vite": "catalog:",
|
|
43
|
+
"vitest": "catalog:"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
import { isTailwindEntry } from './index.js'
|
|
6
|
+
|
|
7
|
+
function cssFile(contents: string) {
|
|
8
|
+
const dir = mkdtempSync(join(tmpdir(), 'poveste-tw-'))
|
|
9
|
+
const file = join(dir, 'entry.css')
|
|
10
|
+
writeFileSync(file, contents)
|
|
11
|
+
return file
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('isTailwindEntry', () => {
|
|
15
|
+
it('accepts a Tailwind import', () => {
|
|
16
|
+
expect(isTailwindEntry(cssFile(`@import 'tailwindcss';`))).toBe(true)
|
|
17
|
+
expect(isTailwindEntry(cssFile(`@import "tailwindcss";`))).toBe(true)
|
|
18
|
+
expect(isTailwindEntry(cssFile(`@import 'tailwindcss/theme' layer(theme);`))).toBe(true)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('accepts a theme block', () => {
|
|
22
|
+
expect(isTailwindEntry(cssFile('@theme {\n --color-brand: red;\n}'))).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('rejects a stylesheet that merely imports something', () => {
|
|
26
|
+
// The case this exists for. `examples/sveltekit` has no Tailwind at all, and
|
|
27
|
+
// its `src/app.css` opens with a font import — enough to satisfy any test
|
|
28
|
+
// looser than this one, and it was getting a Design System group and a
|
|
29
|
+
// Tailwind story rendering Tailwind's own defaults.
|
|
30
|
+
expect(isTailwindEntry(cssFile(`@import '@fontsource/fira-mono';\n\n:root { --pure-white: #fff }`))).toBe(false)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('rejects a name that only looks like Tailwind', () => {
|
|
34
|
+
expect(isTailwindEntry(cssFile('.tailwindcss { color: red }'))).toBe(false)
|
|
35
|
+
expect(isTailwindEntry(cssFile('/* @import tailwindcss was here */'))).toBe(false)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('rejects a file it cannot read', () => {
|
|
39
|
+
expect(isTailwindEntry(join(tmpdir(), 'poveste-tw-does-not-exist.css'))).toBe(false)
|
|
40
|
+
})
|
|
41
|
+
})
|