Skip to content

Commit 6c37306

Browse files
committed
Fix CSS render issue in ChatGPT in external packages take 2
1 parent 9248e95 commit 6c37306

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

packages/sunpeak/bin/commands/dev.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ export async function dev(projectRoot = process.cwd(), args = []) {
182182
console.log(`\nStarting MCP server with ${simulations.length} simulation(s)...`);
183183

184184
// Virtual entry module plugin for MCP
185+
// Import sunpeak styles directly via JS to avoid CSS @import alias issues with Lightning CSS.
186+
// Then import app.css for user's @source directives and custom styles (no sunpeak import).
187+
const sunpeakStylePath = isTemplate ? `${parentSrc}/style.css` : 'sunpeak/style.css';
188+
185189
const sunpeakEntryPlugin = () => ({
186190
name: 'sunpeak-entry',
187191
resolveId(id) {
@@ -202,7 +206,8 @@ export async function dev(projectRoot = process.cwd(), args = []) {
202206
return `
203207
import { createElement } from 'react';
204208
import { createRoot } from 'react-dom/client';
205-
import '/src/styles/globals.css';
209+
import '${sunpeakStylePath}';
210+
import '/src/styles/app.css';
206211
import * as ResourceModule from '${srcPath}';
207212
208213
const Component = ResourceModule.default || ResourceModule['${componentName}'];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* User-specific Tailwind configuration and custom styles */
2+
3+
/* Scan app-specific source files for Tailwind classes */
4+
@source "../**/*.{ts,tsx}";
5+
6+
/* Required for Tailwind to find class references in Apps SDK UI components. */
7+
@source "../../node_modules/@openai/apps-sdk-ui";
8+
9+
/* Configure dark mode to use data-theme attribute (OpenAI SDK standard) */
10+
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
11+
12+
/* Add your custom styles below */
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
/* sunpeak/style.css handles tailwindcss and @openai/apps-sdk-ui/css imports */
1+
/* Base styles: Tailwind CSS + OpenAI Apps SDK UI */
22
@import "sunpeak/style.css";
33

4-
/* Scan app-specific source files for Tailwind classes */
5-
@source "../**/*.{ts,tsx}";
6-
7-
/* Required for Tailwind to find class references in Apps SDK UI components. */
8-
@source "../../node_modules/@openai/apps-sdk-ui";
9-
10-
/* Configure dark mode to use data-theme attribute (OpenAI SDK standard) */
11-
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
4+
/* App-specific configuration and custom styles */
5+
@import "./app.css";

0 commit comments

Comments
 (0)