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 *.njsproj
*.sln *.sln
*.sw? *.sw?
# local env files
!.env.*
.env*.local

View File

@ -3,9 +3,9 @@
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "TAMAGUI_TARGET='web' vite", "dev": "TAMAGUI_TARGET=web vite",
"build": "tsc && vite build", "build": "tsc && TAMAGUI_TARGET=web vite build",
"preview": "vite preview", "preview": "TAMAGUI_TARGET=web vite preview",
"lint": "eslint src", "lint": "eslint src",
"typecheck": "tsc", "typecheck": "tsc",
"clean": "rimraf node_modules .turbo" "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 { tamaguiPlugin } from '@tamagui/vite-plugin'
import react from '@vitejs/plugin-react-swc' import react from '@vitejs/plugin-react-swc'
import path from 'path' import path from 'path'
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import type { PluginOption } from 'vite' import type { PluginOption } from 'vite'
process.env.TAMAGUI_TARGET = 'web'
process.env.TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD = '1'
const tamaguiConfig = { const tamaguiConfig = {
components: ['@status-im/components'], components: ['@status-im/components'],
config: './tamagui.config.ts', config: './tamagui.config.ts',
@ -15,7 +12,10 @@ const tamaguiConfig = {
} }
// @see: https://vitejs.dev/config // @see: https://vitejs.dev/config
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
resolve: { resolve: {
// mainFields: ['module', 'jsnext:main', 'jsnext'], // mainFields: ['module', 'jsnext:main', 'jsnext'],
alias: { alias: {
@ -26,11 +26,14 @@ export default defineConfig({
}, },
}, },
define: { define: {
TAMAGUI_TARGET: JSON.stringify('web'), // @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: [ plugins: [
react(), react(),
tamaguiPlugin(tamaguiConfig) as PluginOption, tamaguiPlugin(tamaguiConfig) as PluginOption,
// tamaguiExtractPlugin(tamaguiConfig) // tamaguiExtractPlugin(tamaguiConfig)
], ],
}
}) })

View File

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

View File

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

View File

@ -5,7 +5,7 @@
"main": false "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", "installCommand": "yarn install --cwd ../../ --frozen-lockfile",
"buildCommand": "turbo run build --cwd ../../ --filter=website..." "buildCommand": "turbo run build --cwd ../../ --filter=website..."
} }

View File

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