Skip to content

Commit 228390e

Browse files
committed
feat(plugin): initial commit
0 parents  commit 228390e

File tree

17 files changed

+5559
-0
lines changed

17 files changed

+5559
-0
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
max_line_length = 120
11+
12+
[*.md]
13+
max_line_length = off
14+
trim_trailing_whitespace = false
15+
16+
[*.ts]
17+
ij_typescript_force_semicolon_style = true
18+
ij_typescript_use_semicolon_after_statement = true
19+
ij_typescript_spaces_within_imports = true
20+
21+
[*.json]
22+
ij_json_array_wrapping = off
23+
ij_json_keep_blank_lines_in_code = 0
24+
ij_json_keep_indents_on_empty_lines = false
25+
ij_json_keep_line_breaks = true
26+
ij_json_keep_trailing_comma = true
27+
ij_json_object_wrapping = off
28+
ij_json_property_alignment = do_not_align
29+
ij_json_space_after_colon = true
30+
ij_json_space_after_comma = true
31+
ij_json_space_before_colon = false
32+
ij_json_space_before_comma = false
33+
ij_json_spaces_within_braces = false
34+
ij_json_spaces_within_brackets = false
35+
ij_json_wrap_long_lines = false

.github/actions/setup/action.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Setup
3+
description: Setup the environment for the project
4+
5+
inputs:
6+
node-version:
7+
description: Node.js version
8+
default: '24'
9+
required: false
10+
node-registry:
11+
description: Node.js package registry to set up for auth
12+
required: false
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ inputs.node-version }}
21+
registry-url: ${{ inputs.node-registry }}
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
26+
- name: Get pnpm store directory
27+
id: pnpm-cache-dir
28+
shell: bash
29+
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
30+
31+
- name: Setup pnpm cache
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.pnpm-cache-dir.outputs.dir }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
shell: bash
41+
run: pnpm install --prefer-frozen-lockfile

.github/images/nz-made.png

489 KB
Loading

.github/workflows/release.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
gh-release:
11+
name: Create GitHub Release
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
19+
- name: Create release
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: gh release create "$GITHUB_REF_NAME" --generate-notes
23+
24+
publish-npm:
25+
name: Publish to NPM
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
id-token: write
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v5
33+
34+
- name: Setup
35+
uses: ./.github/actions/setup
36+
with:
37+
node-registry: https://registry.npmjs.org
38+
39+
- name: Publish to NPM
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
NPM_CONFIG_PROVENANCE: true
43+
run: pnpm publish --no-git-checks --access public

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
node_modules/
3+
dist/
4+
.DS_Store

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
eslint.config.ts

.prettierignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Add files and folders here to ignore them from prettier formatting
2+
3+
# Prettier default
4+
**/.git
5+
**/.svn
6+
**/.hg
7+
**/node_modules
8+
9+
# Dirs
10+
dist
11+
.idea
12+
13+
# Files
14+
README.md
15+
**/*.json
16+
**/*.yaml

.prettierrc.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
arrowParens: always
3+
bracketSpacing: true
4+
embeddedLanguageFormatting: auto
5+
htmlWhitespaceSensitivity: css
6+
insertPragma: false
7+
jsxSingleQuote: true
8+
printWidth: 120
9+
proseWrap: preserve
10+
quoteProps: as-needed
11+
requirePragma: false
12+
semi: true
13+
singleQuote: true
14+
tabWidth: 2
15+
trailingComma: none
16+
useTabs: false
17+
overrides:
18+
- files: '*.ts'
19+
options:
20+
parser: typescript

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025-present Ryan Bosher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# @bosh-code/tsdown-plugin-tailwindcss
2+
3+
[![npm version](https://img.shields.io/npm/v/@bosh-code/tsdown-plugin-tailwindcss)](https://npmjs.com/package/@bosh-code/tsdown-plugin-tailwindcss)
4+
[![npm downloads](https://img.shields.io/npm/dm/@bosh-code/tsdown-plugin-tailwindcss)](https://npmjs.com/package/@bosh-code/tsdown-plugin-tailwindcss)
5+
6+
Use [tailwindcss](https://tailwindcss.com/) in your [tsdown](https://tsdown.dev/) component libraries.
7+
8+
The `@tailwindcss/vite` plugin unfortunately doesn't work with tsdown, so I created this plugin which is a modified version of that plugin but with tsdown support.
9+
This plugin extracts classes from your source files and enables use of libraries like [daisyui](https://daisyui.com/), just like the vite plugin.
10+
11+
I intend for this plugin to be used with [@bosh-code/tsdown-plugin-inject-css](https://www.npmjs.com/package/@bosh-code/tsdown-plugin-inject-css), as you need someway of importing the built CSS in the bundle.
12+
You can achieve the same result in other ways if you would prefer not to use the plugin, but I find the plugin to be nicer.
13+
14+
## Installation
15+
16+
Install the plugin:
17+
18+
```shell
19+
# npm
20+
npm install -D @bosh-code/tsdown-plugin-inject-css @bosh-code/tsdown-plugin-tailwindcss
21+
22+
# yarn
23+
yarn add -D @bosh-code/tsdown-plugin-inject-css @bosh-code/tsdown-plugin-tailwindcss
24+
25+
# pnpm
26+
pnpm add -D @bosh-code/tsdown-plugin-inject-css @bosh-code/tsdown-plugin-tailwindcss
27+
```
28+
29+
Add the plugins to your `tsdown.config.ts`:
30+
31+
```ts
32+
// tsdown.config.ts
33+
34+
import { injectCssPlugin } from '@bosh-code/tsdown-plugin-inject-css';
35+
import { tailwindPlugin } from '@bosh-code/tsdown-plugin-tailwindcss';
36+
37+
export default defineConfig({
38+
external: ['preact'],
39+
plugins: [
40+
tailwindPlugin(),
41+
injectCssPlugin()
42+
]
43+
});
44+
45+
```
46+
47+
And add the tailwind import to your library entrypoint CSS file, usually `src/index.css`:
48+
49+
```css
50+
/* src/index.css */
51+
@import "tailwindcss";
52+
53+
/* Add any other global styles here */
54+
```
55+
56+
___
57+
58+
### The how and why
59+
60+
This plugin is a modified version of the [@tailwindcss/vite](https://www.npmjs.com/package/@tailwindcss/vite) plugin that I created to work with my preact component library.
61+
62+
**Contributions welcome!**
63+
64+
### License
65+
66+
MIT © bosh-code
67+
68+
<div align="center" style="max-width: 120px;">
69+
<img style="max-width: 120px" width="120px" src="https://raw.githubusercontent.com/bosh-code/tsdown-plugin-tailwindcss/main/.github/images/nz-made.png">
70+
</div>

0 commit comments

Comments
 (0)