Skip to content

Commit 0f5c820

Browse files
authored
chore: use vite to build cube playground (#5234)
1 parent d8be78a commit 0f5c820

File tree

10 files changed

+614
-132
lines changed

10 files changed

+614
-132
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
run: yarn build
5757
- name: Build other packages
5858
run: yarn lerna run --concurrency 1 build
59+
env:
60+
NODE_OPTIONS: --max_old_space_size=4096
5961
- name: Set NPM token
6062
run: echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ~/.npmrc
6163
env:

.github/workflows/push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ jobs:
206206
run: yarn build
207207
- name: Build other packages
208208
run: yarn lerna run --concurrency 1 build
209+
env:
210+
NODE_OPTIONS: --max_old_space_size=4096
209211

210212
integration-redis:
211213
needs: [unit, lint, latest-tag-sha]

packages/cubejs-playground/config-overrides.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
6+
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
7+
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
8+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
9+
<link rel="stylesheet" href="/antd.min.css">
10+
<meta
11+
name="viewport"
12+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
13+
/>
14+
<meta name="theme-color" content="#000000" />
15+
<link rel="manifest" href="/manifest.json" />
16+
<style>
17+
#playground-root {
18+
height: 100%;
19+
}
20+
</style>
21+
<title>Cube Playground</title>
22+
</head>
23+
<body>
24+
<noscript>You need to enable JavaScript to run this app.</noscript>
25+
<div id="playground-root"></div>
26+
<script type="module" src="/src/index.tsx"></script>
27+
<script>
28+
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";
29+
analytics.load("dSR8JiNYIGKyQHKid9OaLYugXLao18hA");
30+
analytics.page();
31+
}}();
32+
</script>
33+
</body>
34+
</html>

packages/cubejs-playground/package.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,21 @@
1212
"types": "lib/playground/index.d.ts",
1313
"scripts": {
1414
"unit": "react-scripts test",
15-
"dev": "kill-port 3080 && yarn start",
16-
"start": "SKIP_PREFLIGHT_CHECK=true PORT=3080 react-app-rewired start",
15+
"dev": "vite",
1716
"watch": "tsc --noEmit false --watch",
18-
"build": "yarn build:playground && yarn build:lib",
17+
"build": "tsc && yarn build:playground && yarn build:lib",
1918
"build:lib": "tsc --noEmit false && node postbuild.js && cp -R src/img/ lib/img/",
20-
"build:playground": "SKIP_PREFLIGHT_CHECK=true react-app-rewired --max-old-space-size=3072 build && rm -Rf ../cubejs-server-core/playground/** && cp -R build/ ../cubejs-server-core/playground/"
19+
"build:playground": "SKIP_PREFLIGHT_CHECK=true vite build && rm -Rf ../cubejs-server-core/playground/** && cp -R build/ ../cubejs-server-core/playground/"
2120
},
2221
"browserslist": [
23-
">0.2%",
24-
"not dead",
25-
"not ie <= 11",
26-
"not op_mini all"
22+
">0.2% and supports es6-module"
2723
],
2824
"files": [
2925
"public",
3026
"build",
3127
"lib"
3228
],
3329
"homepage": ".",
34-
"proxy": "http://localhost:4000",
3530
"license": "MIT",
3631
"dependencies": {
3732
"@graphiql/toolkit": "^0.4.3",
@@ -79,23 +74,22 @@
7974
"@types/react-router-dom": "^5.1.7",
8075
"@types/styled-components": "5.1.9",
8176
"@types/uuid": "^8.3.1",
77+
"@vitejs/plugin-react": "^2.1.0",
8278
"antd": "4.16.13",
8379
"eslint-config-airbnb": "^18.1.0",
8480
"eslint-plugin-jsx-a11y": "^6.2.1",
8581
"eslint-plugin-react": "^7.20.0",
8682
"fs-extra": "^8.1.0",
8783
"graphql": "^15.8.0",
88-
"less-loader": "^8.1.1",
8984
"prismjs": "^1.25.0",
9085
"react": "^17.0.1",
91-
"react-app-rewire-yarn-workspaces": "^1.0.3",
92-
"react-app-rewired": "^2.1.0",
9386
"react-dom": "^17.0.1",
9487
"react-scripts": "4.0.3",
9588
"recursive-readdir": "^2.2.2",
9689
"styled-components": "5.2.0",
9790
"tslib": "^2.3.0",
98-
"typescript": "4.8.2"
91+
"typescript": "4.8.2",
92+
"vite": "^3.1.0"
9993
},
10094
"peerDependencies": {
10195
"@ant-design/icons": ">=4.7.0",

packages/cubejs-playground/public/index.html

Lines changed: 0 additions & 57 deletions
This file was deleted.

packages/cubejs-playground/src/index.less

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/cubejs-playground/src/playground/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import './index.less';
2+
3+
export * from '../cloud';
14
export * from './components/QueryBuilder';
25
export * from '../hooks';
36
export { fetchPoll } from '../utils';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
4+
export default defineConfig(({ mode }) => ({
5+
build: {
6+
outDir: 'build',
7+
target: 'es2018',
8+
},
9+
server: {
10+
port: 3080,
11+
proxy: {
12+
'^/playground/*': 'http://localhost:4000',
13+
'^/cubejs-api/*': 'http://localhost:4000',
14+
},
15+
},
16+
plugins: [react()],
17+
css: {
18+
preprocessorOptions: {
19+
less: {
20+
javascriptEnabled: true,
21+
additionalData: '@root-entry-name: default;',
22+
},
23+
},
24+
},
25+
26+
define:
27+
mode === 'development'
28+
? {
29+
global: {},
30+
}
31+
: undefined,
32+
}));

0 commit comments

Comments
 (0)