Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

refactor(ui): switch to vite for building and bundling #1012

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ bin/
**/.vagrant
/cloud-config.cfg
db.db
ui/build/
site/
dist
3 changes: 2 additions & 1 deletion ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
/node_modules
/build
5 changes: 3 additions & 2 deletions ui/public/index.html → ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="manifest" href="/manifest.json" />
<title>VMClarity</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
6 changes: 0 additions & 6 deletions ui/jsconfig.json

This file was deleted.

20,327 changes: 2,912 additions & 17,415 deletions ui/package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vmclarity",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@turingpointde/cvss.js": "^1.4.7",
"classnames": "^2.3.2",
Expand All @@ -17,7 +18,6 @@
"react-error-boundary": "^4.0.9",
"react-js-cron": "^3.1.0",
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"react-select": "^5.7.0",
"react-table": "^7.8.0",
"react-time-picker": "^5.2.0",
Expand All @@ -27,14 +27,16 @@
"sass": "^1.58.0",
"spinners-react": "^1.0.7"
},
"overrides": {
"nth-check": "^2.0.1",
"webpack": "^5.76.0"
"devDependencies": {
"@vitejs/plugin-react": "^4.2.1",
"esbuild-plugin-browserslist": "^0.10.0",
"vite": "^5.0.6",
"vite-tsconfig-paths": "^4.2.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
Expand All @@ -53,6 +55,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:8080"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const FieldError = ({children}) => (
<div className="form-field-error">{children}</div>
);

export default FieldError;
export default FieldError;
File renamed without changes.
5 changes: 4 additions & 1 deletion ui/src/index.js → ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import App from 'layout/App';
import 'utils/fonts/fonts.scss';

const container = document.getElementById('root');
if (container === null) {
throw new Error('Root element not found');
}
const root = createRoot(container);

root.render(<App />);
root.render(<App />);
File renamed without changes.
29 changes: 29 additions & 0 deletions ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"baseUrl": "src",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["vite/client"]
},
"include": [
"src"
]
}
1 change: 1 addition & 0 deletions ui/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
38 changes: 38 additions & 0 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import { esbuildPluginBrowserslist } from 'esbuild-plugin-browserslist';
import { browserslist } from './package.json';

const PROXY_TARGET = 'http://localhost:8080';

export default defineConfig(({ mode }) => {
return {
base: '',
plugins: [
react(),
viteTsconfigPaths(),
esbuildPluginBrowserslist(mode === 'production' ? browserslist.production : browserslist.development),
],
build: {
outDir: 'build',
},
resolve: {
alias: {
utils: '/src/utils',
}
},
server: {
open: true,
port: 3000,
proxy: {
'/api': {
target: PROXY_TARGET,
},
'/ui/api': {
target: PROXY_TARGET,
},
},
},
}
});