Skip to content

Commit

Permalink
feat: Set output to standalone and add deploy command to facilitate d…
Browse files Browse the repository at this point in the history
…eployment of the project infiniflow#1841
  • Loading branch information
cike8899 committed Nov 7, 2024
1 parent 292cf84 commit 89d0ca7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": ["next/core-web-vitals", "next/typescript", "prettier"]
"extends": ["next/core-web-vitals", "next/typescript", "prettier"],
"ignorePatterns": ["copy.js"]
}
30 changes: 30 additions & 0 deletions gui/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');

const nextStaticPath = path.join(__dirname, '.next', 'static');
const nextStandalonePath = path.join(
__dirname,
'.next',
'standalone',
'public',
'_next'
);

function copyFolderRecursiveSync(src, dest) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();
if (isDirectory) {
fs.mkdirSync(dest, { recursive: true });
fs.readdirSync(src).forEach((childItemName) => {
copyFolderRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName)
);
});
} else {
fs.copyFileSync(src, dest);
}
}

copyFolderRecursiveSync(nextStaticPath, nextStandalonePath);
2 changes: 2 additions & 0 deletions gui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const { codeInspectorPlugin } = require('code-inspector-plugin');

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',

images: {
remotePatterns: [
{
Expand Down
6 changes: 4 additions & 2 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"dev": "next dev -p 3033",
"build": "next build",
"start": "next start -p 3043",
"lint": "next lint"
"lint": "next lint",
"copy": "node copy.js",
"deploy": "next build && pnpm run copy"
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
Expand Down Expand Up @@ -66,4 +68,4 @@
"@types/react-dom": "npm:[email protected]"
}
}
}
}

0 comments on commit 89d0ca7

Please sign in to comment.