Skip to content

Commit 3910ecd

Browse files
ryanontheinstideeliteprox
ryanontheinstide
authored andcommitted
support both 'npm run build' and 'npm run dev'
1 parent 12162b6 commit 3910ecd

6 files changed

+49
-12
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ Install dependencies
170170
```bash
171171
cd ui
172172
npm install --legacy-peer-deps
173+
npm install --save-dev cross-env
173174
```
174175

175176
Run local dev server:

ui/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update
2020

2121
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
2222

23+
> **Note for ComfyUI Node Development:**
24+
> - `npm run dev` uses a separate `./.next` directory that won't affect the ComfyUI node's static files
25+
> - `npm run build` creates production files in `../nodes/web/static` for use by the ComfyUI node
26+
2327
## Learn More
2428

2529
To learn more about Next.js, take a look at the following resources:

ui/next.config.ts

+18-8
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ const getExtensionName = () => {
1919

2020
const extensionName = getExtensionName();
2121

22+
// Check if we're in development mode
23+
// This is set by the NEXT_PUBLIC_DEV environment variable in package.json scripts
24+
const isDev = process.env.NEXT_PUBLIC_DEV === 'true';
25+
console.log(`Running in ${isDev ? 'DEVELOPMENT' : 'PRODUCTION'} mode`);
26+
console.log(`Output directory: ${isDev ? './.next' : '../nodes/web/static'}`);
27+
28+
const distDir = isDev ? './.next' : '../nodes/web/static';
29+
2230
const nextConfig: NextConfig = {
23-
output: 'export',
24-
distDir: '../nodes/web/static',
31+
output: isDev ? undefined : 'export',
32+
distDir: distDir,
2533
// Set base path for the app when served from ComfyUI
26-
basePath: `/extensions/${extensionName}/static`,
34+
basePath: isDev ? '' : `/extensions/${extensionName}/static`,
2735
// Set asset prefix for static files
28-
assetPrefix: `/extensions/${extensionName}/static`,
36+
assetPrefix: isDev ? '' : `/extensions/${extensionName}/static`,
2937
// Disable image optimization since we're doing static export
3038
images: {
3139
unoptimized: true,
@@ -34,11 +42,13 @@ const nextConfig: NextConfig = {
3442
// Only run ESLint during development, not during builds
3543
ignoreDuringBuilds: true,
3644
},
37-
// Test comment
3845
};
3946

4047
export default nextConfig;
4148

42-
//to build:
43-
// cd ui
44-
// ./node_modules/.bin/next build
49+
/*
50+
Build Commands:
51+
--------------
52+
- Development: npm run dev (uses ./.next directory)
53+
- Production: npm run build (uses ../nodes/web/static directory)
54+
*/

ui/package-lock.json

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
7-
"dev:https": "next dev --experimental-https",
8-
"build": "next build",
6+
"dev": "cross-env NEXT_PUBLIC_DEV=true next dev",
7+
"dev:https": "cross-env NEXT_PUBLIC_DEV=true next dev --experimental-https",
8+
"build": "cross-env NEXT_PUBLIC_DEV=false next build",
99
"start": "next start",
1010
"lint": "next lint"
1111
},
@@ -34,6 +34,7 @@
3434
"@types/node": "^20",
3535
"@types/react": "^18",
3636
"@types/react-dom": "^18",
37+
"cross-env": "^7.0.3",
3738
"eslint": "^8",
3839
"eslint-config-next": "15.0.2",
3940
"postcss": "^8",

ui/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"../nodes/web/static/types/**/*.ts",
3535
".next/types/**/*.ts",
3636
"next-env.d.ts",
37-
"out/types/**/*.ts"
37+
"out/types/**/*.ts",
38+
"./.next/types/**/*.ts"
3839
],
3940
"exclude": [
4041
"node_modules"

0 commit comments

Comments
 (0)