@bunup/plugin-tailwindcss 0.11.23 → 0.11.28
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 +3 -3
- package/package.json +8 -7
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -54
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bunup/plugin-tailwindcss
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Bunup plugin for creating libraries with Tailwind CSS.
|
|
4
4
|
|
|
5
|
-
Learn more
|
|
5
|
+
Learn more: https://bunup.dev/docs/builtin-plugins/tailwindcss
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunup/plugin-tailwindcss",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.11.
|
|
3
|
+
"description": "The official Bunup plugin for creating libraries with Tailwind CSS.",
|
|
4
|
+
"version": "0.11.28",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
|
|
@@ -27,9 +28,8 @@
|
|
|
27
28
|
],
|
|
28
29
|
"keywords": [
|
|
29
30
|
"bunup",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"tailwindcss"
|
|
31
|
+
"tailwindcss",
|
|
32
|
+
"bunup-tailwindcss"
|
|
33
33
|
],
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tailwindcss/postcss": "^4.1.
|
|
49
|
+
"@tailwindcss/postcss": "^4.1.13",
|
|
50
|
+
"lightningcss": "^1.30.1",
|
|
50
51
|
"postcss": "^8.5.6"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BunPlugin } from "bun";
|
|
2
|
-
/**
|
|
3
|
-
* Configuration options for the TailwindCSS plugin
|
|
4
|
-
*/
|
|
5
|
-
type TailwindCSSOptions = {
|
|
6
|
-
/** CSS class prefix to apply for scoping. Defaults to 'bunup' */
|
|
7
|
-
prefix?: string
|
|
8
|
-
};
|
|
9
|
-
declare function tailwindcss(options?: TailwindCSSOptions): BunPlugin;
|
|
10
|
-
export { tailwindcss as default };
|
package/dist/index.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// packages/plugin-tailwindcss/src/index.ts
|
|
2
|
-
import tailwindPostcss from "@tailwindcss/postcss";
|
|
3
|
-
import postcss from "postcss";
|
|
4
|
-
function tailwindcss(options = {}) {
|
|
5
|
-
return {
|
|
6
|
-
name: "bunup:tailwindcss",
|
|
7
|
-
setup: (build) => {
|
|
8
|
-
const { prefix = "bunup" } = options;
|
|
9
|
-
const rewriter = new HTMLRewriter;
|
|
10
|
-
build.onLoad({ filter: /\.(tsx|jsx)$/ }, async (args) => {
|
|
11
|
-
const source = await Bun.file(args.path).text();
|
|
12
|
-
rewriter.on("*", {
|
|
13
|
-
element(elem) {
|
|
14
|
-
const currentClassName = elem.getAttribute("className");
|
|
15
|
-
const scopedClassName = currentClassName?.split(" ").map((c) => `${!c.includes(prefix) ? `${prefix}-` : ""}${c}`).join(" ");
|
|
16
|
-
if (scopedClassName)
|
|
17
|
-
elem.setAttribute("className", scopedClassName);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const result = rewriter.transform(source);
|
|
21
|
-
return {
|
|
22
|
-
loader: args.path.endsWith(".tsx") ? "tsx" : "jsx",
|
|
23
|
-
contents: result
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
27
|
-
const source = await Bun.file(args.path).text();
|
|
28
|
-
const result = await postcss([
|
|
29
|
-
tailwindPostcss({
|
|
30
|
-
base: build.config.root,
|
|
31
|
-
transformAssetUrls: false
|
|
32
|
-
}),
|
|
33
|
-
{
|
|
34
|
-
postcssPlugin: "scoping",
|
|
35
|
-
Rule(rule) {
|
|
36
|
-
rule.selector = rule.selector.replace(/\.([\w-\\/]+)/g, (_, cls) => {
|
|
37
|
-
return `.${prefix}-${cls}`;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]).process(source, {
|
|
42
|
-
from: args.path
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
contents: result.css,
|
|
46
|
-
loader: "css"
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
tailwindcss as default
|
|
54
|
-
};
|