Set up web app deployment (#399)

* env

* vercel.json

* u

* global

* ignore

* preview

* vercel

* turbo

* fix turbo

* rm TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD

* use globaThis
This commit is contained in:
Felicio Mununga 2023-05-16 13:04:47 +02:00 committed by GitHub
parent 539eb6f35d
commit 12428280cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 52 additions and 26 deletions

1
apps/web/.env Normal file
View File

@ -0,0 +1 @@
TAMAGUI_TARGET=web

View File

@ -0,0 +1 @@
TAMAGUI_TARGET=web

1
apps/web/.env.production Normal file
View File

@ -0,0 +1 @@
TAMAGUI_TARGET=web

4
apps/web/.gitignore vendored
View File

@ -22,3 +22,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?
# local env files
!.env.*
.env*.local

View File

@ -3,9 +3,9 @@
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "TAMAGUI_TARGET='web' vite",
"build": "tsc && vite build",
"preview": "vite preview",
"dev": "TAMAGUI_TARGET=web vite",
"build": "tsc && TAMAGUI_TARGET=web vite build",
"preview": "TAMAGUI_TARGET=web vite preview",
"lint": "eslint src",
"typecheck": "tsc",
"clean": "rimraf node_modules .turbo"

11
apps/web/vercel.json Normal file
View File

@ -0,0 +1,11 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"git": {
"deploymentEnabled": {
"main": false
}
},
"ignoreCommand": "git diff --quiet HEAD^ HEAD ../../{patches,package.json,turbo.json} ../../packages/{colors,components,icons,status-js} ./",
"installCommand": "yarn install --cwd ../../ --frozen-lockfile",
"buildCommand": "turbo run build --cwd ../../ --filter=web..."
}

View File

@ -1,13 +1,10 @@
import { tamaguiPlugin } from '@tamagui/vite-plugin'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import type { PluginOption } from 'vite'
process.env.TAMAGUI_TARGET = 'web'
process.env.TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD = '1'
const tamaguiConfig = {
components: ['@status-im/components'],
config: './tamagui.config.ts',
@ -15,22 +12,28 @@ const tamaguiConfig = {
}
// @see: https://vitejs.dev/config
export default defineConfig({
resolve: {
// mainFields: ['module', 'jsnext:main', 'jsnext'],
alias: {
'@status-im/components/hooks': path.resolve(
'../../packages/components/hooks'
),
'@status-im/components': path.resolve('../../packages/components/src'),
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
resolve: {
// mainFields: ['module', 'jsnext:main', 'jsnext'],
alias: {
'@status-im/components/hooks': path.resolve(
'../../packages/components/hooks'
),
'@status-im/components': path.resolve('../../packages/components/src'),
},
},
},
define: {
TAMAGUI_TARGET: JSON.stringify('web'),
},
plugins: [
react(),
tamaguiPlugin(tamaguiConfig) as PluginOption,
// tamaguiExtractPlugin(tamaguiConfig)
],
define: {
// @see https://github.com/tamagui/tamagui/blob/a0d5fa0d05e6988a7cfa2a5e7823f295b82bae10/packages/tamagui/src/setup.ts#LL20C1-L20C28
global: 'globalThis',
'process.env.TAMAGUI_TARGET': JSON.stringify(env.TAMAGUI_TARGET),
},
plugins: [
react(),
tamaguiPlugin(tamaguiConfig) as PluginOption,
// tamaguiExtractPlugin(tamaguiConfig)
],
}
})

View File

@ -26,6 +26,7 @@ yarn-error.log*
.pnpm-debug.log*
# local env files
!.env.*
.env*.local
# vercel

View File

@ -9,7 +9,7 @@
"lint": "next lint",
"typecheck": "tsc",
"clean": "rimraf .next .tamagui .vercel/output node_modules",
"serve": "next start --port 8151"
"preview": "next start --port 8151"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.0.3",

View File

@ -5,7 +5,7 @@
"main": false
}
},
"ignoreCommand": "git diff --quiet HEAD^ HEAD ../../{patches,package.json} ../../packages/{colors,components,icons} ./",
"ignoreCommand": "git diff --quiet HEAD^ HEAD ../../{patches,package.json,turbo.json} ../../packages/{colors,components,icons,status-js} ./",
"installCommand": "yarn install --cwd ../../ --frozen-lockfile",
"buildCommand": "turbo run build --cwd ../../ --filter=website..."
}

View File

@ -5,6 +5,10 @@
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"web#build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"website#build": {
"dependsOn": ["^build"],
"env": ["TAMAGUI_TARGET", "TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD"],