Skip to content

Commit

Permalink
Merge pull request #923 from andrew-bierman/feat/move-tauri-to-vite
Browse files Browse the repository at this point in the history
Feat/move tauri to vite
  • Loading branch information
andrew-bierman authored May 11, 2024
2 parents fc83f69 + 621cbfc commit 08b8454
Show file tree
Hide file tree
Showing 71 changed files with 6,682 additions and 1,659 deletions.
24 changes: 24 additions & 0 deletions .github/scripts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ const viteFileContent = envFileContent
.join('\n');
fs.writeFileSync(viteOutputPath, `${autogeneratedComment}\n${viteFileContent}`);

/**
* Generate Tauri .env file content
*/
const tauriOutputPath = path.join(
__dirname,
'..',
'..',
'apps',
'tauri',
outputName,
);

const tauriFileContent = envFileContent
.split('\n')
.map((line) => {
if (line.startsWith('PUBLIC_')) {
// We use Vite's env variables in Tauri
return line.replace(/^PUBLIC_/, 'VITE_');
}
})
.join('\n');
fs.writeFileSync(tauriOutputPath, `${autogeneratedComment}\n${tauriFileContent}`);


// TODO: Add wrangler env generation
/**
* Generate Cloudflare Wrangler .dev.vars file content
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ drizzle.config.d.ts
# Tamagui
.tamagui

*.apk

# Logs
logs
*.log
Expand Down
44 changes: 0 additions & 44 deletions apps/tauri/.babelrc

This file was deleted.

18 changes: 18 additions & 0 deletions apps/tauri/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
56 changes: 21 additions & 35 deletions apps/tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
31 changes: 29 additions & 2 deletions apps/tauri/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## Prerequisites
# React + TypeScript + Vite

[tauri]: https://tauri.app/v1/guides/getting-started/prerequisites
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
1 change: 0 additions & 1 deletion apps/tauri/app-env.d.ts

This file was deleted.

11 changes: 1 addition & 10 deletions apps/tauri/envResolver.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
export const NODE_ENV = process.env.NODE_ENV || 'development';
export const API_URL = process.env.API_URL || 'http://localhost:3000/api';
export const NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN =
process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN;

export default {
NODE_ENV,
API_URL,
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN,
};
export * from '@packrat/config';
13 changes: 13 additions & 0 deletions apps/tauri/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PackRat</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/App.tsx"></script>
</body>
</html>
5 changes: 0 additions & 5 deletions apps/tauri/next-env.d.ts

This file was deleted.

Loading

0 comments on commit 08b8454

Please sign in to comment.