build: add baseUrl

main
spacemeowx2 2023-03-03 22:06:14 +08:00 committed by imspace
parent 401fd35bd0
commit b76faea133
8 changed files with 75 additions and 24 deletions

12
gui/.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

View File

@ -25,6 +25,7 @@
"postcss": "^8.4.21", "postcss": "^8.4.21",
"tailwindcss": "^3.2.7", "tailwindcss": "^3.2.7",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"vite": "^4.1.4" "vite": "^4.1.4",
"vite-tsconfig-paths": "^4.0.5"
} }
} }

View File

@ -15,6 +15,7 @@ specifiers:
tailwindcss: ^3.2.7 tailwindcss: ^3.2.7
typescript: ^4.9.5 typescript: ^4.9.5
vite: ^4.1.4 vite: ^4.1.4
vite-tsconfig-paths: ^4.0.5
dependencies: dependencies:
'@tauri-apps/api': 1.2.0 '@tauri-apps/api': 1.2.0
@ -33,6 +34,7 @@ devDependencies:
tailwindcss: 3.2.7_postcss@8.4.21 tailwindcss: 3.2.7_postcss@8.4.21
typescript: 4.9.5 typescript: 4.9.5
vite: 4.1.4_@types+node@18.14.5 vite: 4.1.4_@types+node@18.14.5
vite-tsconfig-paths: 4.0.5_typescript@4.9.5
packages: packages:
@ -950,6 +952,10 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
dev: true dev: true
/globrex/0.1.2:
resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==}
dev: true
/has-flag/3.0.0: /has-flag/3.0.0:
resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==}
engines: {node: '>=4'} engines: {node: '>=4'}
@ -1335,6 +1341,19 @@ packages:
is-number: 7.0.0 is-number: 7.0.0
dev: true dev: true
/tsconfck/2.0.3_typescript@4.9.5:
resolution: {integrity: sha512-o3DsPZO1+C98KqHMdAbWs30zpxD30kj8r9OLA4ML1yghx4khNDzaaShNalfluh8ZPPhzKe3qyVCP1HiZszSAsw==}
engines: {node: ^14.13.1 || ^16 || >=18}
hasBin: true
peerDependencies:
typescript: ^4.3.5
peerDependenciesMeta:
typescript:
optional: true
dependencies:
typescript: 4.9.5
dev: true
/typescript/4.9.5: /typescript/4.9.5:
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
engines: {node: '>=4.2.0'} engines: {node: '>=4.2.0'}
@ -1356,6 +1375,17 @@ packages:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
dev: true dev: true
/vite-tsconfig-paths/4.0.5_typescript@4.9.5:
resolution: {integrity: sha512-/L/eHwySFYjwxoYt1WRJniuK/jPv+WGwgRGBYx3leciR5wBeqntQpUE6Js6+TJemChc+ter7fDBKieyEWDx4yQ==}
dependencies:
debug: 4.3.4
globrex: 0.1.2
tsconfck: 2.0.3_typescript@4.9.5
transitivePeerDependencies:
- supports-color
- typescript
dev: true
/vite/4.1.4_@types+node@18.14.5: /vite/4.1.4_@types+node@18.14.5:
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==} resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}

View File

@ -1,28 +1,17 @@
import { useState } from "react"; import {
import reactLogo from "./assets/react.svg";
import { invoke } from "@tauri-apps/api/tauri"; } from "@tauri-apps/api/window";
import { Routes, Route, Outlet, Link } from "react-router-dom"; import { Routes, Route } from "react-router-dom";
import { Layout } from "components/Layout";
import { Home } from "pages/Home";
function App() { function App() {
return ( return (
<div className="container"> <Routes>
<h1>Welcome to Tauri!</h1> <Route path='/' element={<Layout />}>
<Route index element={<Home />} />
<div className="row"> </Route>
<a href="https://vitejs.dev" target="_blank"> </Routes>
<img src="/vite.svg" className="logo vite" alt="Vite logo" />
</a>
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" className="logo tauri" alt="Tauri logo" />
</a>
<a href="https://reactjs.org" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<div className="row">
</div>
</div>
); );
} }

View File

@ -0,0 +1,10 @@
import React from 'react';
import { Outlet } from "react-router-dom";
export const Layout: React.FC = () => {
return (
<div>
<Outlet />
</div>
);
};

7
gui/src/pages/Home.tsx Normal file
View File

@ -0,0 +1,7 @@
import React from 'react'
export const Home: React.FC = ({ }) => {
return <>
Hello world!
</>
}

View File

@ -3,6 +3,7 @@
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"], "lib": ["DOM", "DOM.Iterable", "ESNext"],
"baseUrl": "src",
"allowJs": false, "allowJs": false,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": false, "esModuleInterop": false,

View File

@ -1,9 +1,10 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import tsconfigPaths from 'vite-tsconfig-paths'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react(), tsconfigPaths()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors // prevent vite from obscuring rust errors