@bhooai/nexus-postcss 0.1.3

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,62 @@
1
+ # @bhooai/nexus-postcss
2
+
3
+ Opinionated PostCSS preset for BhooAI Nexus apps — Tailwind, nesting, future CSS, autoprefixing, and minification in one curated pipeline.
4
+
5
+ ## Install
6
+
7
+ Already included when you scaffold a project with `nexus init`. To add manually:
8
+
9
+ ```bash
10
+ npm install @bhooai/nexus-postcss
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### `postcss.config.js` (default)
16
+
17
+ ```js
18
+ import { createPreset } from '@bhooai/nexus-postcss';
19
+ export default createPreset();
20
+ ```
21
+
22
+ ### With options
23
+
24
+ ```js
25
+ import { createPreset } from '@bhooai/nexus-postcss';
26
+ export default createPreset({
27
+ extraContent: ['../../packages/nexus-admin/src/**/*.{ts,tsx}'],
28
+ minify: true,
29
+ });
30
+ ```
31
+
32
+ ## Plugin chain (in order)
33
+
34
+ 1. **postcss-import** — resolve `@import` statements
35
+ 2. **tailwindcss/nesting** (postcss-nested) — native CSS nesting before `@apply`
36
+ 3. **tailwindcss** — base/components/utilities + content scanning
37
+ 4. **postcss-preset-env** (stage 2) — future CSS features today
38
+ 5. **autoprefixer** — vendor prefixes
39
+ 6. **cssnano** — minification (only when `NODE_ENV=production` or `minify: true`)
40
+
41
+ ## Options
42
+
43
+ | Option | Type | Default | Description |
44
+ | --- | --- | --- | --- |
45
+ | `content` | `string[]` | `['./index.html', './src/**/*.{ts,tsx}']` | Tailwind content scan paths |
46
+ | `extraContent` | `string[]` | `[]` | Additional content paths to merge |
47
+ | `theme` | `object` | `{}` | Tailwind theme extensions |
48
+ | `tailwindPlugins` | `array` | `[]` | Tailwind plugins |
49
+ | `import` | `boolean` | `true` | Enable postcss-import |
50
+ | `nested` | `boolean` | `true` | Enable postcss-nested |
51
+ | `presetEnv` | `boolean \| 'stage2' \| 'stage3' \| 'stage4'` | `true` (stage2) | Enable postcss-preset-env |
52
+ | `autoprefixer` | `boolean \| object` | `true` | Enable autoprefixer (or pass options) |
53
+ | `minify` | `boolean` | `NODE_ENV === 'production'` | Enable cssnano |
54
+ | `plugins` | `Array<[string, any] \| string>` | `[]` | Custom PostCSS plugins to append |
55
+
56
+ ## Tailwind config
57
+
58
+ `tailwind.config.js` is kept in each app — the preset only injects `content` paths and the plugin chain. Theme extensions and Tailwind plugins stay in your `tailwind.config.js`.
59
+
60
+ ## License
61
+
62
+ MIT
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@bhooai/nexus-postcss",
3
+ "version": "0.1.3",
4
+ "description": "Opinionated PostCSS preset for BhooAI Nexus apps — Tailwind, nesting, future CSS, autoprefixing, and minification in one curated pipeline.",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.js",
8
+ "exports": {
9
+ ".": "./src/index.js",
10
+ "./theme.css": "./src/theme.css",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "src"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "test": "vitest run"
19
+ },
20
+ "dependencies": {
21
+ "autoprefixer": "^10.4.20",
22
+ "cssnano": "^7.0.6",
23
+ "postcss": "^8.4.47",
24
+ "postcss-import": "^16.1.0",
25
+ "postcss-nested": "^6.2.0",
26
+ "postcss-preset-env": "^9.6.0",
27
+ "tailwindcss": "^3.4.13"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.5.0",
31
+ "typescript": "^5.6.2",
32
+ "vitest": "^2.1.1"
33
+ }
34
+ }
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createPreset } from './plugins.js';
package/src/plugins.js ADDED
@@ -0,0 +1,46 @@
1
+ import postcssImport from 'postcss-import';
2
+ import postcssNested from 'postcss-nested';
3
+ import tailwindcss from 'tailwindcss';
4
+ import postcssPresetEnv from 'postcss-preset-env';
5
+ import autoprefixer from 'autoprefixer';
6
+ import cssnano from 'cssnano';
7
+
8
+ export function createPreset(options = {}) {
9
+ const DEFAULT_CONTENT = ['./index.html', './src/**/*.{ts,tsx}'];
10
+ const PRESET_ENV_STAGES = ['stage2', 'stage3', 'stage4'];
11
+ const env = process.env.NODE_ENV ?? 'development';
12
+ const shouldMinify = options.minify ?? env === 'production';
13
+ const presetEnvStage = PRESET_ENV_STAGES.includes(options.presetEnv)
14
+ ? options.presetEnv
15
+ : 'stage2';
16
+ const enablePresetEnv = options.presetEnv !== false;
17
+ const enableImport = options.import ?? true;
18
+ const enableNested = options.nested ?? true;
19
+ const enableAutoprefixer = options.autoprefixer !== false;
20
+
21
+ const content = [...(options.content ?? DEFAULT_CONTENT), ...(options.extraContent ?? [])];
22
+ const tailwindOpts = {
23
+ content,
24
+ theme: options.theme ?? {},
25
+ plugins: options.tailwindPlugins ?? [],
26
+ };
27
+
28
+ const plugins = [];
29
+ if (enableImport) plugins.push(postcssImport({}));
30
+ if (enableNested) plugins.push(postcssNested({}));
31
+ plugins.push(tailwindcss(tailwindOpts));
32
+ if (enablePresetEnv) plugins.push(postcssPresetEnv({ stage: presetEnvStage }));
33
+ if (enableAutoprefixer) {
34
+ const apOpts = typeof options.autoprefixer === 'object' ? options.autoprefixer : {};
35
+ plugins.push(autoprefixer(apOpts));
36
+ }
37
+ if (shouldMinify) plugins.push(cssnano({ preset: 'default' }));
38
+ if (options.plugins) {
39
+ for (const p of options.plugins) {
40
+ if (typeof p === 'string') plugins.push(p);
41
+ else plugins.push(p[0](p[1] ?? {}));
42
+ }
43
+ }
44
+
45
+ return { plugins };
46
+ }
package/src/theme.css ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @bhooai/nexus-postcss — theme.css
3
+ *
4
+ * Framework-wide design tokens for Nexus apps. Opt in with:
5
+ * @import '@bhooai/nexus-postcss/theme.css';
6
+ *
7
+ * All tokens are CSS custom properties on :root so they cascade
8
+ * naturally and can be overridden per-app or per-component.
9
+ * Values target the default dark surface; override any token in
10
+ * your own :root block to retheme.
11
+ */
12
+
13
+ :root {
14
+ /* ---- base surface ---- */
15
+ --nexus-bg: #050817;
16
+ --nexus-bg-alt: #0b0d1a;
17
+ --nexus-ink: #eef6ff;
18
+ --nexus-muted: #8496ad;
19
+ --nexus-surface: rgba(10, 24, 45, 0.78);
20
+ --nexus-surface-strong: rgba(8, 25, 48, 0.68);
21
+ --nexus-border: rgba(125, 174, 235, 0.2);
22
+ --nexus-border-bright: rgba(112, 168, 228, 0.17);
23
+
24
+ /* ---- accent palette ---- */
25
+ --nexus-accent: #67e8f9;
26
+ --nexus-accent-soft: rgba(103, 232, 249, 0.08);
27
+ --nexus-blue: rgba(38, 130, 225, 0.55);
28
+ --nexus-violet: rgba(90, 67, 183, 0.45);
29
+ --nexus-pink: #f43f5e;
30
+ --nexus-emerald: #34d399;
31
+
32
+ /* ---- geometry ---- */
33
+ --nexus-radius: 0.7rem;
34
+ --nexus-radius-lg: 1rem;
35
+ --nexus-shell-width: 1280px;
36
+
37
+ /* ---- ambient mesh ---- */
38
+ --nexus-mesh:
39
+ radial-gradient(54rem 42rem at 84% -12%, rgba(91, 33, 182, 0.32), transparent 67%),
40
+ radial-gradient(48rem 38rem at -8% 58%, rgba(8, 145, 178, 0.2), transparent 68%),
41
+ radial-gradient(42rem 36rem at 56% 44%, rgba(30, 64, 175, 0.16), transparent 72%);
42
+ --nexus-mesh-opacity: 0.27;
43
+
44
+ /* ---- selection + scrollbars ---- */
45
+ --nexus-selection: rgba(129, 140, 248, 0.35);
46
+ --nexus-scrollbar: rgba(255, 255, 255, 0.18);
47
+ --nexus-scrollbar-thumb: rgba(255, 255, 255, 0.14);
48
+
49
+ /* ---- aliases for existing admin consumers ---- */
50
+ --admin-bg: var(--nexus-bg);
51
+ --admin-ink: var(--nexus-ink);
52
+ --admin-muted: var(--nexus-muted);
53
+ --admin-surface: var(--nexus-surface);
54
+ --admin-surface-strong: var(--nexus-surface-strong);
55
+ --admin-border: var(--nexus-border);
56
+ --admin-border-bright: var(--nexus-border-bright);
57
+ --admin-blue: var(--nexus-blue);
58
+ --admin-violet: var(--nexus-violet);
59
+ --admin-pink: var(--nexus-pink);
60
+ --admin-radius: var(--nexus-radius);
61
+ --admin-shell-width: var(--nexus-shell-width);
62
+ --admin-mesh: var(--nexus-mesh);
63
+ --admin-mesh-opacity: var(--nexus-mesh-opacity);
64
+ }
package/src/types.ts ADDED
@@ -0,0 +1,12 @@
1
+ export interface NexusPostcssOptions {
2
+ content?: string[];
3
+ extraContent?: string[];
4
+ theme?: Record<string, any>;
5
+ tailwindPlugins?: any[];
6
+ import?: boolean;
7
+ nested?: boolean;
8
+ presetEnv?: boolean | 'stage2' | 'stage3' | 'stage4';
9
+ autoprefixer?: boolean | Record<string, string>;
10
+ minify?: boolean;
11
+ plugins?: Array<[string, any] | string>;
12
+ }