mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-21 18:02:32 +01:00
vite
This commit is contained in:
parent
469366d2bf
commit
c1d515b26a
13
.eslintrc
13
.eslintrc
@ -1,15 +1,18 @@
|
|||||||
{
|
{
|
||||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"plugins": ["@typescript-eslint"],
|
"plugins": ["react-refresh"],
|
||||||
"root": true,
|
"root": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-mixed-spaces-and-tabs": "off",
|
"no-mixed-spaces-and-tabs": "off",
|
||||||
"@typescript-eslint/no-var-requires": "off",
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
"@typescript-eslint/no-unused-vars": "off"
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
|
"react-refresh/only-export-components": ["warn", { "allowConstantExport": true }]
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"node": true
|
"browser": true,
|
||||||
}
|
"es2020": true
|
||||||
|
},
|
||||||
|
"ignorePatterns": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
const CracoEsbuildPlugin = require("craco-esbuild");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
plugin: CracoEsbuildPlugin,
|
|
||||||
options: {
|
|
||||||
esbuildMinimizerOptions: {
|
|
||||||
target: "ESNext",
|
|
||||||
},
|
|
||||||
esbuildLoaderOptions: {
|
|
||||||
loader: "tsx",
|
|
||||||
target: "ESNext",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
44
index.html
Normal file
44
index.html
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<!-- Primary Meta Tags -->
|
||||||
|
<meta name="title" content="Spacebar Client - For better and secure communication" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat."
|
||||||
|
/>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#121212" />
|
||||||
|
|
||||||
|
<!-- Open Graph / Facebook -->
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:url" content="https://spacebar.chat/" />
|
||||||
|
<meta property="og:title" content="Spacebar Client - For better and secure communication" />
|
||||||
|
<meta
|
||||||
|
property="og:description"
|
||||||
|
content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat."
|
||||||
|
/>
|
||||||
|
<meta property="og:image" content="%PUBLIC_URL%/Spacebar.png" />
|
||||||
|
|
||||||
|
<!-- Twitter -->
|
||||||
|
<meta property="twitter:card" content="summary_large_image" />
|
||||||
|
<meta property="twitter:url" content="https://spacebar.chat/" />
|
||||||
|
<meta property="twitter:title" content="Spacebar Client - For better and secure communication" />
|
||||||
|
<meta
|
||||||
|
property="twitter:description"
|
||||||
|
content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat."
|
||||||
|
/>
|
||||||
|
<meta property="twitter:image" content="%PUBLIC_URL%/Spacebar.png" />
|
||||||
|
|
||||||
|
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
|
||||||
|
<title>Spacebar</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>
|
75
package.json
75
package.json
@ -1,16 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "spacebar-client",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/spacebarchat/client.git"
|
|
||||||
},
|
|
||||||
"author": "Spacebar",
|
"author": "Spacebar",
|
||||||
"license": "AGPL-3.0-only",
|
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/spacebarchat/client/issues"
|
"url": "https://github.com/spacebarchat/client/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://app.spacebar.chat",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.11.0",
|
"@emotion/react": "^11.11.0",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
@ -21,6 +13,8 @@
|
|||||||
"@mdi/js": "^7.2.96",
|
"@mdi/js": "^7.2.96",
|
||||||
"@mdi/react": "^1.6.1",
|
"@mdi/react": "^1.6.1",
|
||||||
"@mui/material": "^5.13.0",
|
"@mui/material": "^5.13.0",
|
||||||
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
||||||
|
"@rollup/plugin-replace": "^5.0.2",
|
||||||
"@spacebarchat/spacebar-api-types": "0.37.49",
|
"@spacebarchat/spacebar-api-types": "0.37.49",
|
||||||
"@tauri-apps/api": "2.0.0-alpha.6",
|
"@tauri-apps/api": "2.0.0-alpha.6",
|
||||||
"@tauri-apps/plugin-authenticator": "2.0.0-alpha.1",
|
"@tauri-apps/plugin-authenticator": "2.0.0-alpha.1",
|
||||||
@ -35,10 +29,6 @@
|
|||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"@types/jest": "^27.5.2",
|
|
||||||
"@types/node": "^16.18.28",
|
|
||||||
"@types/react": "^18.2.6",
|
|
||||||
"@types/react-dom": "^18.2.4",
|
|
||||||
"framer-motion": "^10.16.1",
|
"framer-motion": "^10.16.1",
|
||||||
"missing-native-js-functions": "^1.4.3",
|
"missing-native-js-functions": "^1.4.3",
|
||||||
"mobx": "^6.9.0",
|
"mobx": "^6.9.0",
|
||||||
@ -54,48 +44,47 @@
|
|||||||
"react-loading-skeleton": "^3.3.1",
|
"react-loading-skeleton": "^3.3.1",
|
||||||
"react-moment": "^1.1.3",
|
"react-moment": "^1.1.3",
|
||||||
"react-router-dom": "^6.11.1",
|
"react-router-dom": "^6.11.1",
|
||||||
"react-scripts": "5.0.1",
|
|
||||||
"react-secure-storage": "^1.3.0",
|
"react-secure-storage": "^1.3.0",
|
||||||
"react-select-search": "^4.1.6",
|
"react-select-search": "^4.1.6",
|
||||||
"react-spinners": "^0.13.8",
|
"react-spinners": "^0.13.8",
|
||||||
"reoverlay": "^1.0.3",
|
"reoverlay": "^1.0.3",
|
||||||
"styled-components": "^5.3.10",
|
"styled-components": "^5.3.10",
|
||||||
"typescript": "^4.9.5"
|
"vite-plugin-svgr": "^3.2.0"
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "craco start",
|
|
||||||
"build": "craco build",
|
|
||||||
"test": "craco test",
|
|
||||||
"lint": "eslint .",
|
|
||||||
"lint:fix": "pnpx prettier . --write"
|
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
||||||
"extends": [
|
|
||||||
"react-app",
|
|
||||||
"react-app/jest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"browserslist": {
|
|
||||||
"production": [
|
|
||||||
">0.2%",
|
|
||||||
"not dead",
|
|
||||||
"not op_mini all"
|
|
||||||
],
|
|
||||||
"development": [
|
|
||||||
"last 1 chrome version",
|
|
||||||
"last 1 firefox version",
|
|
||||||
"last 1 safari version"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@craco/craco": "^7.1.0",
|
"@craco/craco": "^7.1.0",
|
||||||
"@tauri-apps/cli": "2.0.0-alpha.11",
|
"@tauri-apps/cli": "2.0.0-alpha.11",
|
||||||
|
"@types/jest": "^27.5.2",
|
||||||
"@types/loadable__component": "^5.13.4",
|
"@types/loadable__component": "^5.13.4",
|
||||||
|
"@types/node": "^16.18.28",
|
||||||
|
"@types/react": "^18.2.15",
|
||||||
|
"@types/react-dom": "^18.2.7",
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||||
"@typescript-eslint/parser": "^5.59.5",
|
"@typescript-eslint/parser": "^6.0.0",
|
||||||
|
"@vitejs/plugin-react": "^4.0.4",
|
||||||
"craco-esbuild": "^0.5.2",
|
"craco-esbuild": "^0.5.2",
|
||||||
"eslint": "^8.40.0"
|
"eslint": "^8.45.0",
|
||||||
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
|
"eslint-plugin-react-refresh": "^0.4.3",
|
||||||
|
"typescript": "^5.0.2",
|
||||||
|
"vite": "^4.4.5"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@8.7.0"
|
"homepage": "https://spacebar.chat",
|
||||||
|
"license": "AGPL-3.0-only",
|
||||||
|
"name": "spacebar-client",
|
||||||
|
"packageManager": "pnpm@8.7.0",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/spacebarchat/client.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"dev": "vite",
|
||||||
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
|
"lint:fix": "pnpx prettier . --write",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.1.0"
|
||||||
}
|
}
|
||||||
|
4294
pnpm-lock.yaml
4294
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,44 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<!-- Primary Meta Tags -->
|
|
||||||
<meta name="title" content="Spacebar Client - For better and secure communication">
|
|
||||||
<meta name="description" content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat.">
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<meta name="theme-color" content="#000000" />
|
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
|
||||||
<meta property="og:type" content="website">
|
|
||||||
<meta property="og:url" content="https://spacebar.chat/">
|
|
||||||
<meta property="og:title" content="Spacebar Client - For better and secure communication">
|
|
||||||
<meta property="og:description" content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat.">
|
|
||||||
<meta property="og:image" content="%PUBLIC_URL%/Spacebar.png">
|
|
||||||
|
|
||||||
<!-- Twitter -->
|
|
||||||
<meta property="twitter:card" content="summary_large_image">
|
|
||||||
<meta property="twitter:url" content="https://spacebar.chat/">
|
|
||||||
<meta property="twitter:title" content="Spacebar Client - For better and secure communication">
|
|
||||||
<meta property="twitter:description" content="Spacebar is a free and open source software compatible with Discord. It's a chat, voice and video platform similar to Slack and Rocket.chat.">
|
|
||||||
<meta property="twitter:image" content="%PUBLIC_URL%/Spacebar.png">
|
|
||||||
|
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
||||||
|
|
||||||
<title>Spacebar</title>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
html,
|
|
||||||
body,
|
|
||||||
#root,
|
|
||||||
#root > div {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
||||||
<div id="root"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -161,6 +161,7 @@ export const ModalFullSidebar = styled.div`
|
|||||||
flex: 1 0 11.35%;
|
flex: 1 0 11.35%;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
background-color: var(--background-secondary);
|
background-color: var(--background-secondary);
|
||||||
|
padding: 10px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const ModalFullSidebarContent = styled.div`
|
export const ModalFullSidebarContent = styled.div`
|
||||||
@ -174,6 +175,7 @@ export const ModalFullContent = styled.div`
|
|||||||
flex: 1 1 42.3%;
|
flex: 1 1 42.3%;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
background-color: var(--background-primary);
|
background-color: var(--background-primary);
|
||||||
|
padding: 10px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface ModalProps extends StackedModalProps {
|
interface ModalProps extends StackedModalProps {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { useModals } from "@mattjennings/react-modal-stack";
|
import { useModals } from "@mattjennings/react-modal-stack";
|
||||||
import { useAppStore } from "../../stores/AppStore";
|
import { useAppStore } from "../../stores/AppStore";
|
||||||
|
import { GIT_BRANCH, GIT_REVISION, REPO_URL } from "../../utils/revison";
|
||||||
import Button from "../Button";
|
import Button from "../Button";
|
||||||
import Icon from "../Icon";
|
import Icon from "../Icon";
|
||||||
import {
|
import {
|
||||||
@ -48,7 +49,20 @@ function SettingsModal(props: AnimatedModalProps) {
|
|||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</ModalCloseWrapper>
|
</ModalCloseWrapper>
|
||||||
Content
|
<div>
|
||||||
|
<span>Client Version: </span>
|
||||||
|
<a href={`${REPO_URL}/commit/${GIT_REVISION}`} target="_blank" rel="noreferrer">
|
||||||
|
{GIT_REVISION.substring(0, 7)}
|
||||||
|
</a>
|
||||||
|
{` `}
|
||||||
|
<a
|
||||||
|
href={GIT_BRANCH !== "DETACHED" ? `${REPO_URL}/tree/${GIT_BRANCH}` : undefined}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
({GIT_BRANCH})
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</ModalFullContent>
|
</ModalFullContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
6
src/custom.d.ts
vendored
Normal file
6
src/custom.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
declare module "*.svg" {
|
||||||
|
import React = require("react");
|
||||||
|
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
@ -1,3 +1,10 @@
|
|||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root,
|
||||||
|
#root > div {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
|
@ -21,8 +21,7 @@ import { ContextMenuContextProvider } from "./contexts/ContextMenuContext";
|
|||||||
import Theme from "./contexts/Theme";
|
import Theme from "./contexts/Theme";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
|
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||||
root.render(
|
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<ModalStack renderModals={ModalRenderer}>
|
<ModalStack renderModals={ModalRenderer}>
|
||||||
<ContextMenuContextProvider>
|
<ContextMenuContextProvider>
|
||||||
|
1
src/react-app-env.d.ts
vendored
1
src/react-app-env.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference types="react-scripts" />
|
|
4
src/utils/revison.ts
Normal file
4
src/utils/revison.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export const REPO_URL: string = "https://github.com/spacebarchat/client";
|
||||||
|
export const GIT_REVISION: string = "__GIT_REVISION__";
|
||||||
|
export const GIT_BRANCH: string = "__GIT_BRANCH__";
|
||||||
|
export const APP_VERSION = "__APP_VERSION__";
|
1
src/vite-env.d.ts
vendored
Normal file
1
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
@ -1,22 +1,27 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"useDefineForClassFields": true,
|
||||||
"allowJs": true,
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true,
|
"experimentalDecorators": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"emitDecoratorMetadata": true,
|
||||||
"strict": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
/* Bundler mode */
|
||||||
"noFallthroughCasesInSwitch": true,
|
"moduleResolution": "bundler",
|
||||||
"module": "esnext",
|
"allowImportingTsExtensions": true,
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"experimentalDecorators": true,
|
|
||||||
"emitDecoratorMetadata": true
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
// "noUnusedLocals": true,
|
||||||
|
// "noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src", "src/custom.d.ts"],
|
||||||
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
}
|
}
|
||||||
|
10
tsconfig.node.json
Normal file
10
tsconfig.node.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
80
vite.config.ts
Normal file
80
vite.config.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import { esbuildCommonjs } from "@originjs/vite-plugin-commonjs";
|
||||||
|
import replace from "@rollup/plugin-replace";
|
||||||
|
import react from "@vitejs/plugin-react";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
import svgr from "vite-plugin-svgr";
|
||||||
|
|
||||||
|
function getGitRevision() {
|
||||||
|
try {
|
||||||
|
const rev = readFileSync(".git/HEAD").toString().trim();
|
||||||
|
if (rev.indexOf(":") === -1) {
|
||||||
|
return rev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return readFileSync(`.git/${rev.substring(5)}`)
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to get Git revision.");
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGitBranch() {
|
||||||
|
try {
|
||||||
|
const rev = readFileSync(".git/HEAD").toString().trim();
|
||||||
|
if (rev.indexOf(":") === -1) {
|
||||||
|
return "DETACHED";
|
||||||
|
}
|
||||||
|
|
||||||
|
return rev.split("/").pop();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to get Git branch.");
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVersion() {
|
||||||
|
return JSON.parse(readFileSync("package.json").toString()).version;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
react(),
|
||||||
|
svgr(),
|
||||||
|
replace({
|
||||||
|
__GIT_REVISION__: getGitRevision(),
|
||||||
|
__GIT_BRANCH__: getGitBranch(),
|
||||||
|
__APP_VERSION__: getVersion(),
|
||||||
|
preventAssignment: true,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
}) as any,
|
||||||
|
],
|
||||||
|
optimizeDeps: {
|
||||||
|
esbuildOptions: {
|
||||||
|
plugins: [esbuildCommonjs(["react-moment"])],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
sourcemap: true,
|
||||||
|
rollupOptions: {
|
||||||
|
input: {
|
||||||
|
main: resolve(__dirname, "index.html"),
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
dir: "build",
|
||||||
|
chunkFileNames: "[hash:20].js",
|
||||||
|
entryFileNames: "[hash:20].js",
|
||||||
|
inlineDynamicImports: false,
|
||||||
|
experimentalMinChunkSize: 500_000,
|
||||||
|
manualChunks(id) {
|
||||||
|
if (id.includes("node_modules")) {
|
||||||
|
return id.toString().split("node_modules/")[1].split("/")[0].toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user