From 053ba2520a9d2b0e4bd8c07f5941beae9afc0935 Mon Sep 17 00:00:00 2001 From: lukachi Date: Thu, 16 May 2024 18:27:15 +0300 Subject: [PATCH] upd build and ci --- .env-development | 3 --- .env-analyze => .env.development | 2 +- .env-production => .env.production | 1 - .../workflows/actions.yml | 3 +-- .../workflows/actions_onlymain.yml | 3 +-- {.github.workflows.example => .github}/workflows/tag.yml | 4 ++-- .gitignore | 2 -- package.json | 4 ++-- vite.config.ts | 7 ++++--- werf.yaml | 3 ++- 10 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 .env-development rename .env-analyze => .env.development (79%) rename .env-production => .env.production (77%) rename {.github.workflows.example => .github}/workflows/actions.yml (90%) rename {.github.workflows.example => .github}/workflows/actions_onlymain.yml (94%) rename {.github.workflows.example => .github}/workflows/tag.yml (94%) diff --git a/.env-development b/.env-development deleted file mode 100644 index 5529ecb..0000000 --- a/.env-development +++ /dev/null @@ -1,3 +0,0 @@ -VITE_ENVIRONMENT=development -VITE_API_URL='https://jsonplaceholder.typicode.com' -VITE_APP_NAME='React Template' diff --git a/.env-analyze b/.env.development similarity index 79% rename from .env-analyze rename to .env.development index 9b6ac8f..b525bb6 100644 --- a/.env-analyze +++ b/.env.development @@ -1,4 +1,4 @@ -VITE_ENVIRONMENT=analyze VITE_PORT=8095 VITE_API_URL='https://jsonplaceholder.typicode.com' VITE_APP_NAME='React Template' + diff --git a/.env-production b/.env.production similarity index 77% rename from .env-production rename to .env.production index 2e35105..bc00d79 100644 --- a/.env-production +++ b/.env.production @@ -1,4 +1,3 @@ -VITE_ENVIRONMENT=production VITE_PORT=8095 VITE_API_URL='https://jsonplaceholder.typicode.com' VITE_APP_NAME='React Template' diff --git a/.github.workflows.example/workflows/actions.yml b/.github/workflows/actions.yml similarity index 90% rename from .github.workflows.example/workflows/actions.yml rename to .github/workflows/actions.yml index 5095565..7ff1190 100644 --- a/.github.workflows.example/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -27,8 +27,7 @@ jobs: echo $GITHUB_SHA - name: Run Build env: # Or as an environment variable -# VITE_APP_DOMAIN: https://my.domain.com + VITE_MODE: 'development' run: | - cp .env-development .env . $(werf ci-env github --as-file) werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA diff --git a/.github.workflows.example/workflows/actions_onlymain.yml b/.github/workflows/actions_onlymain.yml similarity index 94% rename from .github.workflows.example/workflows/actions_onlymain.yml rename to .github/workflows/actions_onlymain.yml index 22c8fc8..c69d169 100644 --- a/.github.workflows.example/workflows/actions_onlymain.yml +++ b/.github/workflows/actions_onlymain.yml @@ -29,9 +29,8 @@ jobs: echo $GITHUB_SHA - name: Run Build env: # Or as an environment variable -# VITE_APP_DOMAIN: https://my.domain.com + VITE_MODE: 'staging' run: | - cp .env-development .env . $(werf ci-env github --as-file) werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA diff --git a/.github.workflows.example/workflows/tag.yml b/.github/workflows/tag.yml similarity index 94% rename from .github.workflows.example/workflows/tag.yml rename to .github/workflows/tag.yml index 8b51c28..14f1795 100644 --- a/.github.workflows.example/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -27,11 +27,11 @@ jobs: docker version echo $GITHUB_REPOSITORY echo $GITHUB_REF_NAME + - name: Run Build env: # Or as an environment variable -# VITE_APP_DOMAIN: https://my.domain.com + VITE_MODE: 'production' run: | - cp .env-production .env . $(werf ci-env github --as-file) werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME diff --git a/.gitignore b/.gitignore index 0f480e0..e76ce33 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,5 @@ stats.html !.yarn/sdks !.yarn/versions -.env.production -.env.development .env.analyze tsconfig.tsbuildinfo diff --git a/package.json b/package.json index 8bcf3cc..5602915 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "pre-push": "yarn rsc" }, "scripts": { - "build": "dotenv -e .env vite build", - "start": "dotenv -e .env vite", + "build": "vite build", + "start": "vite", "analyze": "vite build --mode analyze", "lint": "yarn lint:styles && yarn lint:scripts", "lint:styles": "stylelint \"src/**/*.{css,sass,scss}\" --max-warnings=0", diff --git a/vite.config.ts b/vite.config.ts index 482d3db..0ee72b8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,9 +22,10 @@ const root = path.resolve(__dirname, resolveApp('src')) export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') - // const isProduction = env.VITE_ENVIRONMENT === 'production' - // const isDevelopment = env.VITE_ENVIRONMENT === 'development' - const isAnalyze = env.VITE_ENVIRONMENT === 'analyze' + // const isProduction = mode === 'production' + // const isDevelopment = mode === 'development' + const isAnalyze = mode === 'analyze' + // const buildVersion = env.VITE_APP_BUILD_VERSION return { diff --git a/werf.yaml b/werf.yaml index 7b1e2f0..d7cda7e 100644 --- a/werf.yaml +++ b/werf.yaml @@ -22,7 +22,8 @@ shell: - yarn install setup: - cd /app - - yarn build + - export VITE_MODE="{{ env "VITE_MODE" }}" + - if [ -n "$VITE_MODE" ]; then yarn build --mode $VITE_MODE; else yarn build; fi #- sh -c '[ -d /app/dist/files ] && echo "$FILE exist." || mkdir -p /app/dist/files' #- sh -c '[ -d /app/files ] && echo "$FILE exist." || mkdir -p /app/files' #- sh -c '[ -z "`ls /app/files`" ] && echo "Empty" || cp -r /app/files/* /app/dist/files'