From c6d973e1261d5fb46dd786493bec34afcee761a1 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Wed, 8 Oct 2025 14:34:22 +0200 Subject: [PATCH] CI : create specific build for preprod --- .gitlab-ci.yml | 28 ++++++++++++++++- package.json | 1 + public/site/config/config.php | 2 +- vite.config.js | 58 +++++++++++++++++++---------------- 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8617d19..2108350 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ build: script: - apk add --no-cache nodejs npm - npm install - - npm run build + - if [ "$CI_COMMIT_REF_NAME" = "dev" ]; then npm run build:preprod; else npm run build; fi - cd dist - composer install --no-dev --optimize-autoloader --ignore-platform-req=ext-gd - cd .. @@ -48,3 +48,29 @@ deploy: rsync_deploy vendor/ "$PROD_PATH/vendor/" rsync_deploy kirby/ "$PROD_PATH/kirby/" rsync_deploy assets/ "$PROD_PATH/assets/" "--exclude 'tiles/'" + +deploy_dev: + stage: deploy + image: node:latest + only: + - dev + before_script: + - apt-get update -qq && apt-get install -y rsync sshpass + script: + - cd dist + - | + rsync_deploy() { + local src=$1 + local dst=$2 + local exclude=$3 + cmd="sshpass -p \"$PASSWORD\" rsync -az --delete -O" + [[ -n $exclude ]] && cmd="$cmd $exclude" + cmd="$cmd -e 'ssh -p 2244 -o StrictHostKeyChecking=no' $src $USERNAME@$HOST:$dst" + echo "$cmd" + eval $cmd + } + + rsync_deploy site/ "$PREPROD_PATH/site/" "--exclude 'accounts/' --exclude 'cache/' --exclude 'sessions/'" + rsync_deploy vendor/ "$PREPROD_PATH/vendor/" + rsync_deploy kirby/ "$PREPROD_PATH/kirby/" + rsync_deploy assets/ "$PREPROD_PATH/assets/" "--exclude 'tiles/'" diff --git a/package.json b/package.json index adb73d0..db18c29 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite", "build": "vite build", + "build:preprod": "vite build --mode=staging", "preview": "vite preview" }, "dependencies": { diff --git a/public/site/config/config.php b/public/site/config/config.php index d4505ea..72ea0da 100644 --- a/public/site/config/config.php +++ b/public/site/config/config.php @@ -3,7 +3,7 @@ $regenerateSteps = require_once(__DIR__ . '/hooks/page-update--regenerate-project-steps-cache.php'); return [ - 'debug' => Dir::exists('assets/dist') ? false: true, + 'debug' => $_SERVER['HTTP_HOST'] !== 'designtopack.groupe-pochet.fr', 'cache' => [ 'pages' => [ 'active' => true diff --git a/vite.config.js b/vite.config.js index 53268a1..c235442 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,33 +1,37 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; -export default defineConfig({ - plugins: [vue()], - base: '/', - build: { - outDir: 'dist', - rollupOptions: { - output: { - entryFileNames: 'assets/dist/[name].js', - assetFileNames: 'assets/dist/[name].[ext]', +export default defineConfig(({ mode }) => { + return { + plugins: [vue()], + base: '/', + build: { + outDir: 'dist', + rollupOptions: { + output: { + entryFileNames: 'assets/dist/[name].js', + assetFileNames: 'assets/dist/[name].[ext]', + }, + }, + sourcemap: mode === 'staging', + minify: mode === 'production' ? 'esbuild' : false, + }, + server: { + watch: { + ignored: [ + '**/node_modules/**', + '**/.git/**', + '**/.cache/**', + '**/.vite/**', + '**/dist/**', + '**/*.log', + '**/.idea/**', + '**/.vscode/**', + '**/public/assets/**', + '**/local/**', + '/public/**', + ], }, }, - }, - server: { - watch: { - ignored: [ - '**/node_modules/**', - '**/.git/**', - '**/.cache/**', - '**/.vite/**', - '**/dist/**', - '**/*.log', - '**/.idea/**', - '**/.vscode/**', - '**/public/assets/**', - '**/local/**', - '/public/**', - ], - }, - }, + }; });