Skip to content

Commit

Permalink
Merge pull request #575 from GraphScope/build-assets
Browse files Browse the repository at this point in the history
feat: Build single assets
  • Loading branch information
pomelo-nwu authored Nov 12, 2024
2 parents 898bd41 + c612c23 commit 2f3ed6a
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 44 deletions.
3 changes: 3 additions & 0 deletions docs/portal/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts


/public/portal.html
82 changes: 50 additions & 32 deletions docs/portal/components/Tools/portal.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
import dynamic from 'next/dynamic';
import { GlobalSpin } from '@graphscope/studio-components';
// import dynamic from 'next/dynamic';
// import { GlobalSpin } from '@graphscope/studio-components';

const Apps = dynamic(
() =>
import('@graphscope/studio-site').then(module => {
return {
/** 这种写法和 react lazy 就统一了 */
default: () => {
return (
<div
style={{
position: 'absolute',
top: '0px',
left: '0px',
bottom: '0px',
right: '0px',
zIndex: 999,
background: '#fff',
}}
>
<module.default />
</div>
);
},
};
}),
{
loading: () => <GlobalSpin />,
ssr: false,
},
);
// const Apps = dynamic(
// () =>
// import('@graphscope/studio-site').then(module => {
// return {
// /** 这种写法和 react lazy 就统一了 */
// default: () => {
// return (
// <div
// style={{
// position: 'absolute',
// top: '0px',
// left: '0px',
// bottom: '0px',
// right: '0px',
// zIndex: 999,
// background: '#fff',
// }}
// >
// <module.default />
// </div>
// );
// },
// };
// }),
// {
// loading: () => <GlobalSpin />,
// ssr: false,
// },
// );

export default Apps;
// export default Apps;

export default () => {
return (
<iframe
style={{
position: 'absolute',
height: '100%',
width: '100%',
top: '0px',
left: '0px',
bottom: '0px',
right: '0px',
zIndex: 999,
}}
src="/portal.html"
></iframe>
);
};
1 change: 1 addition & 0 deletions docs/portal/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const webpack = (config, options) => {
_config.externals.push({
'node:os': 'os',
fsevents: 'fsevents',
// 'monaco-editor': 'monaco',
});

return _config;
Expand Down
2 changes: 1 addition & 1 deletion docs/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build:site": "next build",
"build:site": "cd ../../packages/studio-website && npm run build:site:single && cd ../../docs/portal && next build",
"type-check": "tsc",
"deploy": "gh-pages -d out -t true"
},
Expand Down
9 changes: 9 additions & 0 deletions docs/portal/pages/tools/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@
"layout": "full",
"header": false
}
},
"portal": {
"type": "page",
"title": "Portal",
"theme": {
"footer": false,
"layout": "full",
"header": false
}
}
}
5 changes: 5 additions & 0 deletions docs/portal/pages/tools/portal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import { Bleed } from 'nextra-theme-docs';
import Portal from '../../components/Tools/portal';

<Portal />
2 changes: 1 addition & 1 deletion packages/studio-draw-pattern/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"scripts": {
"dev": "father dev",
"start": "father dev",
"build": "father build",
"build:deps": "father prebundle",
"prepublishOnly": "father doctor && npm run build",
Expand Down
4 changes: 4 additions & 0 deletions packages/studio-graph-editor/.fatherrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
esm: { output: 'es' },
cjs: { output: 'lib' },
};
12 changes: 7 additions & 5 deletions packages/studio-graph-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@graphscope/studio-graph-editor",
"version": "0.1.1",
"description": "",
"main": "./src/index.tsx",
"module": "./src/index.tsx",
"types": "./dist/index.d.ts",
"main": "lib/index.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/GraphScope/portal.git"
Expand All @@ -19,8 +19,10 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"start": "vite dev",
"build": "vite build && tsc"
"start": "father dev",
"build": "father build",
"start:site": "vite dev",
"build:site": "vite build && tsc"
},
"peerDependencies": {
"react": "18.2.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/studio-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"scripts": {
"build": "father build",
"start": "vite dev",
"build:site": "vite build",
"copyHtml": "cp -f dist/index.html ../../docs/portal/public/portal.html",
"build:site:single": "vite build --mode=single && npm run copyHtml",
"build:site": "vite build && npm run copyHtml",
"prepublishOnly": "npm run build"
},
"publishConfig": {
Expand All @@ -26,14 +28,14 @@
"@fortawesome/free-regular-svg-icons": "latest",
"@fortawesome/free-solid-svg-icons": "latest",
"@fortawesome/react-fontawesome": "latest",
"@graphscope/use-zustand": "workspace:*",
"@graphscope/studio-components": "workspace:*",
"@graphscope/studio-driver": "workspace:*",
"@graphscope/studio-explore": "workspace:*",
"@graphscope/studio-graph": "workspace:*",
"@graphscope/studio-importor": "workspace:*",
"@graphscope/studio-query": "workspace:*",
"@graphscope/studio-server": "workspace:*",
"@graphscope/use-zustand": "workspace:*",
"@uiw/react-codemirror": "^4.21.21",
"antd": "^5.17.0",
"js-yaml": "^4.1.0",
Expand Down
21 changes: 19 additions & 2 deletions packages/studio-website/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

import { viteSingleFile } from 'vite-plugin-singlefile';
import dotenv from 'dotenv';

// 获取传递的参数
const args = process.argv.slice(2);

// 解析参数
const params = {};
args.forEach(arg => {
const [key, value] = arg.split('=');
params[key.slice(2)] = value;
});
//@ts-ignore
const { mode } = params;
const isSingle = mode === 'single' && process.env.NODE_ENV === 'production';

console.log('params', params, args);

const plugins = isSingle ? [react(), viteSingleFile()] : [react()];

const { parsed } = dotenv.configDotenv();

const { COORDINATOR_URL } = parsed || {};
Expand All @@ -27,5 +44,5 @@ export default defineConfig({
external: ['node:os', 'fsevents'], // 要排除的模块
},
},
plugins: [react()],
plugins,
});
2 changes: 1 addition & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"rewrites": [
{
"source": "/api/(.*)",
"destination": "https://virtserver.swaggerhub.com/GRAPHSCOPE/flex-api/1.0.0/api/$1"
"destination": "http://127.0.0.1:8080/api/$1"
},
{ "source": "/(.*)", "destination": "/index.html" }
]
Expand Down

0 comments on commit 2f3ed6a

Please sign in to comment.