@tyndall/plugin-css 0.0.1

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 ADDED
@@ -0,0 +1,29 @@
1
+ # @tyndall/plugin-css
2
+
3
+ A build/dev plugin that wires CSS toolchain support into Tyndall bundling. It registers
4
+ esbuild-compatible plugins for vanilla-extract, Sass, and CSS Modules, allowing both
5
+ Bun and esbuild bundlers to resolve styles imported from application code.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import { createCssPipelinePlugin } from "@tyndall/plugin-css";
11
+
12
+ export default {
13
+ plugins: [
14
+ createCssPipelinePlugin({
15
+ identifiers: "debug",
16
+ enableVanillaExtract: true,
17
+ enableSass: true,
18
+ enableCssModules: true,
19
+ }),
20
+ ],
21
+ };
22
+ ```
23
+
24
+ ## Options
25
+
26
+ - `identifiers`: `"short" | "debug"` (defaults to `"short"` in production and `"debug"` otherwise)
27
+ - `enableVanillaExtract`: enable `@vanilla-extract/esbuild-plugin` (default: `true`)
28
+ - `enableSass`: enable `esbuild-sass-plugin` (default: `true`)
29
+ - `enableCssModules`: enable `esbuild-css-modules-plugin` (default: `true`)
@@ -0,0 +1,11 @@
1
+ import type { HyperPlugin } from "@tyndall/core";
2
+ export type CssPipelineIdentifiers = "short" | "debug";
3
+ export interface CssPipelineOptions {
4
+ identifiers?: CssPipelineIdentifiers;
5
+ enableVanillaExtract?: boolean;
6
+ enableSass?: boolean;
7
+ enableCssModules?: boolean;
8
+ }
9
+ export declare const createCssPipelinePlugin: (options?: CssPipelineOptions) => HyperPlugin;
10
+ export declare const cssPipelinePlugin: (options?: CssPipelineOptions) => HyperPlugin;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AAKhE,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,uBAAuB,GAClC,UAAS,kBAAuB,KAC/B,WAgCF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAnCnB,kBAAkB,KAC1B,WAkCqD,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import { vanillaExtractPlugin } from "@vanilla-extract/esbuild-plugin";
2
+ import { sassPlugin } from "esbuild-sass-plugin";
3
+ import * as cssModulesPlugin from "esbuild-css-modules-plugin";
4
+ export const createCssPipelinePlugin = (options = {}) => {
5
+ const { identifiers = process.env.NODE_ENV === "production" ? "short" : "debug", enableVanillaExtract = true, enableSass = true, enableCssModules = true, } = options;
6
+ const vanillaPlugin = enableVanillaExtract
7
+ ? vanillaExtractPlugin({
8
+ identifiers,
9
+ })
10
+ : null;
11
+ const sass = enableSass ? sassPlugin() : null;
12
+ const cssModulesFactory = cssModulesPlugin.default ?? cssModulesPlugin;
13
+ const cssModules = enableCssModules && typeof cssModulesFactory === "function"
14
+ ? cssModulesFactory()
15
+ : null;
16
+ const plugins = [vanillaPlugin, sass, cssModules].filter(Boolean);
17
+ return {
18
+ name: "@tyndall/plugin-css",
19
+ beforeBundle: (ctx) => {
20
+ if (!ctx || typeof ctx.addBundlerPlugin !== "function") {
21
+ return;
22
+ }
23
+ for (const plugin of plugins) {
24
+ ctx.addBundlerPlugin(plugin);
25
+ }
26
+ },
27
+ };
28
+ };
29
+ export const cssPipelinePlugin = createCssPipelinePlugin;
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@tyndall/plugin-css",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "bun": "./src/index.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "lint": "oxlint .",
23
+ "format": "oxfmt ."
24
+ },
25
+ "dependencies": {
26
+ "@tyndall/core": "^0.0.1",
27
+ "@vanilla-extract/esbuild-plugin": "^2.3.0",
28
+ "esbuild-css-modules-plugin": "3.0.0-dev.20",
29
+ "esbuild-sass-plugin": "^2.13.0"
30
+ }
31
+ }