vanilla-jet 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,38 +5,45 @@ on:
5
5
  branches:
6
6
  - main
7
7
 
8
+ permissions:
9
+ id-token: write
10
+ contents: write
11
+
8
12
  jobs:
9
13
  release:
10
14
  name: Publish
11
15
  runs-on: ubuntu-latest
12
- environment: rep
13
16
 
14
17
  steps:
15
18
  - name: Check out the repository
16
- uses: actions/checkout@v3
19
+ uses: actions/checkout@v4
17
20
 
18
21
  - name: Setup Node.js
19
- uses: actions/setup-node@v3
22
+ uses: actions/setup-node@v4
20
23
  with:
21
- node-version: '16'
22
- registry-url: 'https://registry.npmjs.org/'
24
+ node-version: '24'
25
+ registry-url: 'https://registry.npmjs.org'
23
26
 
24
27
  - name: Install dependencies
25
- run: npm install
28
+ run: npm ci
29
+
30
+ - name: Build
31
+ run: npm run build --if-present
32
+
33
+ - name: Test
34
+ run: npm test
26
35
 
27
36
  - name: Publish to npm
28
- env:
29
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30
37
  run: npm publish
31
38
 
32
39
  - name: Configure git identity
33
40
  run: |
34
- git config --global user.email "actions@github.com"
35
- git config --global user.name "GitHub Actions"
41
+ git config user.email "actions@github.com"
42
+ git config user.name "GitHub Actions"
36
43
 
37
44
  - name: Get version from package.json
38
45
  id: get_version
39
- run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
46
+ run: echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT"
40
47
 
41
48
  - name: Check if tag exists
42
49
  run: |
package/CHANGELOG.md ADDED
@@ -0,0 +1,106 @@
1
+ # Changelog
2
+
3
+ All notable project changes are documented in this file.
4
+
5
+ The format follows a structure inspired by Keep a Changelog and semantic versioning.
6
+
7
+ ## [1.4.1] - 2026-02-19
8
+
9
+ ### Highlights (v1.4.1)
10
+
11
+ - Completed HU 2.1 (`Fast path de estaticos en Node`).
12
+ - Optimized static serving in `framework/router.js`:
13
+ - Added warm-path static resolution cache (`route + accept-encoding`) to avoid repeated candidate resolution work.
14
+ - Added bounded metadata revalidation window for conditional requests to reduce repeated `fs.stat` pressure.
15
+ - Consolidated static header assembly and reused mime header maps.
16
+ - Kept stream-based delivery for large assets and tuned `createReadStream` chunk size.
17
+ - Added reproducible local benchmark:
18
+ - New script: `npm run benchmark:static`.
19
+ - New guide: `docs/benchmark-static.md`.
20
+
21
+ ### Compatibility notes (v1.4.1)
22
+
23
+ - No public API changes.
24
+ - Preserves static conditional caching (`304`) and precompressed negotiation fallback.
25
+ - No intended behavior changes for dynamic routes.
26
+
27
+ ## [1.3.6] - 2026-02-19
28
+
29
+ ### Highlights (v1.3.6)
30
+
31
+ - Fixed protected directory typo in `framework/router.js`: `node_mudules` -> `node_modules`.
32
+ - Fixed stability issues in `framework/dipper.js`:
33
+ - `includeAnimations()` now calls the existing `includeAnimation()`.
34
+ - `dequeueStyle()` and `dequeueScript()` now read `item.requires` correctly.
35
+ - Dependency dequeue now runs only when explicitly requested (`dependencies === true`).
36
+ - Fixed `package.json` recursive `test` script to avoid infinite loop and keep `npm test` stable.
37
+ - Completed HU 1.4 hardening milestone and updated roadmap tracking.
38
+
39
+ ### Compatibility notes (v1.3.6)
40
+
41
+ - No public API changes.
42
+ - No route contract changes.
43
+ - This patch only hardens runtime behavior and developer workflow reliability.
44
+
45
+ ## [1.3.5] - 2026-02-19
46
+
47
+ ### Highlights (v1.3.5)
48
+
49
+ - Added safe precompressed fallback in `response.render()` for HTML templates: `.br` (when enabled and accepted) -> `.gz` (when accepted) -> original HTML.
50
+ - Wired `Response` to server profile options, so HTML negotiation follows `settings.profile.enable_precompressed_negotiation`.
51
+ - Added `Vary: Accept-Encoding` for negotiated HTML responses and support for `Accept-Encoding` quality params.
52
+ - Updated documentation and roadmap status for HU 1.3.
53
+
54
+ ## [1.3.4] - 2026-02-19
55
+
56
+ ### Highlights (v1.3.4)
57
+
58
+ - Added optional static precompressed negotiation flag: `settings.profile.enable_precompressed_negotiation`.
59
+ - Static files now resolve safely with fallback chain: `.br` (when enabled and accepted) -> `.gz` (when accepted) -> original file.
60
+ - Static compression negotiation now handles `Accept-Encoding` values with quality params (for example `gzip;q=1.0`).
61
+ - `Vary: Accept-Encoding` is set for negotiated static responses.
62
+
63
+ ## [1.3.3] - 2026-02-18
64
+
65
+ ### Added
66
+
67
+ - Static metadata in-memory cache in `framework/router.js` (`size`, `lastModified`, `etag`) to reduce repeated filesystem work.
68
+ - Conditional request handling for static files using `If-None-Match` and `If-Modified-Since`.
69
+ - Static response headers: `ETag`, `Last-Modified`, and `Cache-Control: no-cache, must-revalidate`.
70
+
71
+ ### Changed
72
+
73
+ - Static files can now return `304 Not Modified` when validators match, reducing transfer for repeated requests.
74
+ - Conditional requests force metadata refresh before deciding `304`, so clients can still see new content without hard reload.
75
+
76
+ ### Compatibility notes
77
+
78
+ - No route or filename contract changes.
79
+ - No impact on dynamic endpoints behavior.
80
+
81
+ ## [1.3.2] - 2026-02-18
82
+
83
+ ### Current documented state
84
+
85
+ - Released version `1.3.2` of `vanilla-jet`.
86
+ - The framework exports `Server` from `index.js` for simple integration in Node.js projects.
87
+ - Includes a Gulp-based build pipeline for:
88
+ - JavaScript minification and concatenation.
89
+ - LESS/CSS compilation and minification.
90
+ - HTML template compilation with Nunjucks.
91
+ - Generation of compressed `.gz` artifacts.
92
+ - Includes HTTP server and optional HTTPS server (self-managed certificates) in `framework/server.js`.
93
+ - Includes internal router with Backbone-style route support (`:param`, `*splat`, optional segments).
94
+ - Includes resource utilities (scripts, styles, meta tags, sentry, environment) in `framework/dipper.js`.
95
+
96
+ ### Compatibility note
97
+
98
+ - This version keeps the historical behavior expected by existing projects.
99
+ - Future improvements are planned with backward compatibility in mind. See `ROADMAP_INTEGRAL.md`.
100
+
101
+ [1.3.3]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.3.3
102
+ [1.3.2]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.3.2
103
+ [1.3.4]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.3.4
104
+ [1.3.5]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.3.5
105
+ [1.3.6]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.3.6
106
+ [1.4.1]: https://github.com/nalancer08/VanillaJet/releases/tag/v1.4.1
package/README.md CHANGED
@@ -1,6 +1,142 @@
1
- <p align="center">
2
- <img src="https://github.com/nalancer08/App-Builders/blob/master/Logos/logo_monocromatico_horizontal_.png">
3
- </p>
4
-
5
1
  # VanillaJet
6
- NodeJS framework to create apps with jQuery or VueJS over a SPA (Single Page Application), the framework helps to create the server and add dependencia, includes router and server side functions as routes (internal API).
2
+
3
+ Node.js framework for building SPA applications with a JS/CSS/HTML build pipeline, HTTP/HTTPS server, internal router, and template rendering utilities.
4
+
5
+ ![VanillaJet logo](https://github.com/nalancer08/App-Builders/blob/master/Logos/logo_monocromatico_horizontal_.png)
6
+
7
+ ## Current version
8
+
9
+ - Version: `1.4.1`
10
+ - Changelog: see [`CHANGELOG.md`](./CHANGELOG.md)
11
+ - Improvement plan (performance and backward compatibility): see `ROADMAP_INTEGRAL.md`
12
+
13
+ ## Requirements
14
+
15
+ - Node.js `>=16` recommended
16
+ - npm `>=8`
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install vanilla-jet
22
+ ```
23
+
24
+ If you are working in this local repository:
25
+
26
+ ```bash
27
+ npm install
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ ### 1) Export the server from your project
33
+
34
+ ```js
35
+ const { Server } = require('vanilla-jet');
36
+ ```
37
+
38
+ ### 2) Define endpoints (classes)
39
+
40
+ Each endpoint should expose a `name` and register routes with the router in the constructor.
41
+
42
+ ```js
43
+ class AppEndpoint {
44
+ constructor(router) {
45
+ this.name = 'AppEndpoint';
46
+ router.addRoute('get', '/', 'AppEndpoint.index');
47
+ }
48
+
49
+ index(request, response) {
50
+ response.setBody('Hello VanillaJet');
51
+ response.respond();
52
+ }
53
+ }
54
+ ```
55
+
56
+ ### 3) Start the server
57
+
58
+ ```js
59
+ const { Server } = require('vanilla-jet');
60
+ const Config = require('./config');
61
+
62
+ new Server(Config, [AppEndpoint]).start();
63
+ ```
64
+
65
+ ## Available commands
66
+
67
+ From this repository:
68
+
69
+ - `npm run setup`: generates a base `vanillaJet.package.json` if it does not exist.
70
+ - `npm run dev`: build + watcher for development.
71
+ - `npm run build:qa`: build for QA.
72
+ - `npm run build:staging`: build for staging.
73
+ - `npm run build:prod`: build for production.
74
+ - `npm run benchmark:static`: runs reproducible static serving benchmark (cold/warm).
75
+
76
+ As CLI (`bin.js`):
77
+
78
+ - `npx vanilla-jet setup`
79
+ - `npx vanilla-jet dev`
80
+ - `npx vanilla-jet build`
81
+
82
+ ## Expected consumer project structure
83
+
84
+ VanillaJet expects a structure similar to:
85
+
86
+ - `assets/pages/home.html`
87
+ - `assets/templates/**/*.html`
88
+ - `assets/scripts/**/*.js`
89
+ - `assets/styles/less/admin.less`
90
+ - `public/` (compiled output)
91
+ - `config.js`
92
+ - `vanillaJet.package.json`
93
+
94
+ ## Build pipeline (summary)
95
+
96
+ - Minifies JS and concatenates into `public/scripts/vanilla.min.js`
97
+ - Compiles LESS and generates `public/styles/app.min.css`
98
+ - Compiles templates and generates `public/pages/home.html`
99
+ - Generates `.gz` versions of JS/CSS/HTML for compressed delivery
100
+
101
+ ## Compression negotiation (optional)
102
+
103
+ You can enable precompressed static negotiation from `settings.profile`:
104
+
105
+ ```js
106
+ module.exports = {
107
+ settings: {
108
+ profile: {
109
+ // Enables priority: .br -> .gz -> original file
110
+ enable_precompressed_negotiation: true
111
+ }
112
+ }
113
+ };
114
+ ```
115
+
116
+ Behavior details:
117
+
118
+ - Default (`false`): keeps existing gzip behavior for supported static assets.
119
+ - Enabled (`true`): if client accepts Brotli, server tries `.br` first.
120
+ - Safe fallback: if `.br` or `.gz` does not exist, server serves the original file.
121
+ - HTML rendering (`response.render`) also uses safe runtime fallback for precompressed templates (`.br`/`.gz`/original).
122
+
123
+ ## Static performance notes (HU 2.1)
124
+
125
+ Static serving includes a warm-path optimization focused on Node runtime latency:
126
+
127
+ - Reuses static resolution for repeated requests (`route + accept-encoding`).
128
+ - Reduces repeated metadata refresh with bounded revalidation windows.
129
+ - Keeps streaming strategy for large assets (`fs.createReadStream`) with tuned chunk size.
130
+ - Preserves conditional cache behavior (`ETag`/`Last-Modified` + `304`) and precompressed fallback contract.
131
+
132
+ Benchmark guide:
133
+
134
+ - [`docs/benchmark-static.md`](./docs/benchmark-static.md)
135
+
136
+ ## Additional documentation
137
+
138
+ - Router: `docs/router.md`
139
+ - Benchmark: [`docs/benchmark-static.md`](./docs/benchmark-static.md)
140
+ - Version history: [`CHANGELOG.md`](./CHANGELOG.md)
141
+ - Roadmap and improvements: `ROADMAP_INTEGRAL.md`
142
+ - Deployment templates (nginx + docker): `docs/deployment/`
@@ -0,0 +1,256 @@
1
+ # ROADMAP INTEGRAL - VanillaJet
2
+
3
+ Documento canonico de planeacion por epicas e historias.
4
+ Cada historia incluye su ciclo completo: fases, tareas, entregables, metricas, criterios y documentacion.
5
+
6
+ ## Objetivo
7
+
8
+ - Maximizar performance de serving estatico sobre Node sin romper compatibilidad.
9
+ - Acelerar el pipeline de compilacion en tiempo real (watch/recompile) para DX diaria.
10
+ - Mejorar flujo `dev` con apertura automatica de navegador y live reload estable.
11
+
12
+ ## Reglas de ejecucion
13
+
14
+ - Retrocompatibilidad primero.
15
+ - Cambios sensibles con flags.
16
+ - Todo cambio con medicion antes/despues.
17
+ - Entregas pequenas y reversibles.
18
+
19
+ ---
20
+
21
+ ## EPIC 1 - Estabilidad base
22
+
23
+ ### HU 1.1 - Cache metadata + 304 (completada `v1.3.3`)
24
+
25
+ #### Fases
26
+ - F1: cache metadata.
27
+ - F2: validacion condicional.
28
+ - F3: no-regresion.
29
+
30
+ #### Tareas
31
+ - Cache `size/mtime/etag`.
32
+ - Soporte `If-None-Match` y `If-Modified-Since`.
33
+
34
+ #### Entregables
35
+ - `framework/router.js` actualizado.
36
+
37
+ #### Metricas
38
+ - Menor latencia y menor I/O en estaticos repetidos.
39
+
40
+ #### Criterios
41
+ - `304` correcto.
42
+ - Sin impacto en dinamico.
43
+
44
+ #### Documentacion
45
+ - `CHANGELOG.md`.
46
+
47
+ ### HU 1.2 - Negociacion `br/gz` estaticos (completada `v1.3.4`)
48
+
49
+ #### Fases
50
+ - F1: flag opt-in.
51
+ - F2: fallback seguro.
52
+ - F3: validacion.
53
+
54
+ #### Tareas
55
+ - `.br -> .gz -> original`.
56
+ - `Vary: Accept-Encoding`.
57
+
58
+ #### Entregables
59
+ - `framework/router.js`.
60
+
61
+ #### Metricas
62
+ - Menor transferencia en cliente.
63
+
64
+ #### Criterios
65
+ - Fallback sin 404.
66
+
67
+ #### Documentacion
68
+ - `README.md`, `CHANGELOG.md`.
69
+
70
+ ### HU 1.3 - Fallback precompressed HTML (completada `v1.3.5`)
71
+
72
+ #### Fases
73
+ - F1: fallback runtime HTML.
74
+ - F2: pruebas de ausencia de artefactos.
75
+ - F3: release.
76
+
77
+ #### Tareas
78
+ - Resolver `.br/.gz/original` en `render`.
79
+
80
+ #### Entregables
81
+ - `framework/response.js`.
82
+
83
+ #### Metricas
84
+ - Menor peso de HTML inicial.
85
+
86
+ #### Criterios
87
+ - Sin errores por artefactos faltantes.
88
+
89
+ #### Documentacion
90
+ - `README.md`, `CHANGELOG.md`.
91
+
92
+ ### HU 1.4 - Hardening de bugs conocidos (completada `v1.3.6`)
93
+
94
+ #### Fases
95
+ - F1: correccion.
96
+ - F2: smoke tests.
97
+ - F3: patch release.
98
+
99
+ #### Tareas
100
+ - [x] `node_mudules -> node_modules`.
101
+ - [x] fixes en `dipper`.
102
+ - [x] fix script `test`.
103
+
104
+ #### Entregables
105
+ - Patch de estabilidad.
106
+
107
+ #### Metricas
108
+ - Menos errores silenciosos en runtime/build.
109
+
110
+ #### Criterios
111
+ - [x] `npm test` estable.
112
+
113
+ #### Documentacion
114
+ - `CHANGELOG.md` con nota de compatibilidad.
115
+
116
+ ---
117
+
118
+ ## EPIC 2 - Performance Node + DX de compilacion (foco actual)
119
+
120
+ ### HU 2.1 - Fast path de estaticos en Node (completada `v1.4.1`)
121
+
122
+ #### Fases
123
+ - F1: profiling de request estatico.
124
+ - F2: optimizacion de lectura/respuesta.
125
+ - F3: validacion de no-regresion.
126
+
127
+ #### Tareas
128
+ - [x] Optimizar resolucion de archivo y headers para evitar trabajo repetido.
129
+ - [x] Revisar estrategia de `fs`/stream para minimizar latencia en assets grandes.
130
+ - [x] Agregar benchmark local reproducible (cold/warm cache).
131
+
132
+ #### Entregables
133
+ - [x] Patch de performance en `framework/router.js`.
134
+ - [x] Script de benchmark local documentado.
135
+
136
+ #### Metricas
137
+ - p95 de estaticos >= 20% mejor en escenario warm.
138
+ - Menor uso de CPU en serving concurrente.
139
+
140
+ #### Criterios
141
+ - [x] Sin romper cache condicional (`304`) ni negociacion precompressed.
142
+ - [x] Sin impacto en rutas dinamicas.
143
+
144
+ #### Documentacion
145
+ - [x] `README.md` + `CHANGELOG.md` + guia de benchmark.
146
+
147
+ ### HU 2.2 - Recompile en tiempo real mas rapido (pendiente)
148
+
149
+ #### Fases
150
+ - F1: baseline de tiempos por tarea de build.
151
+ - F2: optimizacion incremental.
152
+ - F3: validacion en proyecto consumidor.
153
+
154
+ #### Tareas
155
+ - Reducir trabajo redundante en `gulpfile.js` (globs, minify y concatenacion).
156
+ - Mejorar estrategia de watch para recompilar solo lo tocado.
157
+ - Medir tiempo de recompile por tipo de cambio (JS, LESS, HTML).
158
+
159
+ #### Entregables
160
+ - Pipeline `dev` optimizado y medido.
161
+
162
+ #### Metricas
163
+ - Recompile JS >= 35% mas rapido.
164
+ - Recompile LESS >= 30% mas rapido.
165
+
166
+ #### Criterios
167
+ - Output final equivalente al flujo actual.
168
+ - Sin cambios obligatorios en estructura de proyectos consumidores.
169
+
170
+ #### Documentacion
171
+ - `README.md` + `CHANGELOG.md`.
172
+
173
+ ---
174
+
175
+ ## EPIC 3 - Developer Experience en `dev`
176
+
177
+ ### HU 3.1 - Runner `dev` con navegador auto-open + live reload estable (pendiente)
178
+
179
+ #### Fases
180
+ - F1: contrato de ejecucion unificado.
181
+ - F2: implementacion runner.
182
+ - F3: validacion en Mac/Windows/Linux.
183
+
184
+ #### Tareas
185
+ - Abrir navegador automaticamente al iniciar `dev`.
186
+ - Disparar live reload al terminar recompile de assets/templates.
187
+ - Mantener modo fallback para entornos sin navegador.
188
+
189
+ #### Entregables
190
+ - Nuevo flujo `npm run dev` mas simple para consumidores.
191
+
192
+ #### Metricas
193
+ - Tiempo a primer render local menor.
194
+ - Menos pasos manuales de arranque en onboarding.
195
+
196
+ #### Criterios
197
+ - Reload confiable tras cada recompile exitoso.
198
+ - Sin romper el modo actual para usuarios legacy.
199
+
200
+ #### Documentacion
201
+ - `README.md` + `CHANGELOG.md` + guia de migracion de scripts.
202
+
203
+ ---
204
+
205
+ ## EPIC 4 - Hardening operativo del runtime Node
206
+
207
+ ### HU 4.1 - Observabilidad y protecciones de runtime (pendiente)
208
+
209
+ #### Fases
210
+ - F1: logging y metricas base.
211
+ - F2: alarmas y limites.
212
+ - F3: guia operativa.
213
+
214
+ #### Tareas
215
+ - Estandarizar logs de serving estatico y errores.
216
+ - Exponer metricas clave (latencia/errores/cache hits).
217
+ - Documentar manejo de picos y rollback.
218
+
219
+ #### Entregables
220
+ - Guia de operacion y checklist de hardening.
221
+
222
+ #### Documentacion
223
+ - `docs/` + `README.md`.
224
+
225
+ ### HU 4.2 - Paquete de referencia para despliegue Node (pendiente)
226
+
227
+ #### Fases
228
+ - F1: templates de entorno.
229
+ - F2: validacion en staging.
230
+ - F3: guia final.
231
+
232
+ #### Tareas
233
+ - Definir variables, puertos y recomendaciones de cache.
234
+ - Incluir ejemplo de despliegue reproducible para consumidores.
235
+
236
+ #### Entregables
237
+ - Template de despliegue y guia de puesta en marcha.
238
+
239
+ #### Documentacion
240
+ - `docs/` + `README.md`.
241
+
242
+ ---
243
+
244
+ ## Secuencia oficial de ejecucion
245
+
246
+ 1. HU 1.4
247
+ 2. HU 2.1
248
+ 3. HU 2.2
249
+ 4. HU 3.1
250
+ 5. HU 4.1
251
+ 6. HU 4.2
252
+
253
+ ## Estado global
254
+
255
+ - Completado: HU 1.1, HU 1.2, HU 1.3, HU 1.4, HU 2.1.
256
+ - Pendiente: HU 2.2, HU 3.1, HU 4.1, HU 4.2.
@@ -0,0 +1,45 @@
1
+ # Static serving benchmark guide
2
+
3
+ This benchmark measures static file serving in two reproducible scenarios:
4
+
5
+ - Warm cache latency/throughput with stable keep-alive traffic.
6
+ - Cold cache latency by forcing metadata/resolution misses on each request.
7
+
8
+ ## Run
9
+
10
+ ```bash
11
+ npm run benchmark:static
12
+ ```
13
+
14
+ ## Optional tuning variables
15
+
16
+ You can override defaults with environment variables:
17
+
18
+ - `BENCH_PORT` (default: `3199`)
19
+ - `BENCH_FILE_SIZE_KB` (default: `512`)
20
+ - `BENCH_TOTAL_REQUESTS` (default: `2000`)
21
+ - `BENCH_COLD_ITERATIONS` (default: `300`)
22
+
23
+ Example:
24
+
25
+ ```bash
26
+ BENCH_TOTAL_REQUESTS=4000 BENCH_COLD_ITERATIONS=600 npm run benchmark:static
27
+ ```
28
+
29
+ ## Output
30
+
31
+ The script reports for warm and cold scenarios:
32
+
33
+ - request count
34
+ - average latency
35
+ - `p50`, `p95`, `p99`
36
+ - max latency
37
+ - requests per second
38
+
39
+ It also prints warm `p95` improvement vs cold.
40
+
41
+ ## Notes for consistent results
42
+
43
+ - Close heavy apps before running benchmarks.
44
+ - Run at least 3 times and compare medians.
45
+ - Keep the same `BENCH_*` values before/after a performance patch.
@@ -0,0 +1,19 @@
1
+ FROM node:20-alpine
2
+
3
+ WORKDIR /app
4
+
5
+ # Install dependencies first for better layer cache
6
+ COPY package*.json ./
7
+ RUN npm ci
8
+
9
+ # Copy app source
10
+ COPY . .
11
+
12
+ # Build command should generate static output under /app/public
13
+ # Replace with your app build script (for example: npm run build:vite)
14
+ RUN npm run build:vite || npm run build:prod
15
+
16
+ EXPOSE 8080
17
+
18
+ # Replace with your actual backend start command
19
+ CMD ["node", "index.js"]
@@ -0,0 +1,23 @@
1
+ version: "3.9"
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: docs/deployment/Dockerfile.app.example
8
+ container_name: vanillajet-app
9
+ environment:
10
+ - PORT=8080
11
+ expose:
12
+ - "8080"
13
+
14
+ nginx:
15
+ image: nginx:1.27-alpine
16
+ container_name: vanillajet-nginx
17
+ depends_on:
18
+ - app
19
+ ports:
20
+ - "80:80"
21
+ volumes:
22
+ - ./public:/app/public:ro
23
+ - ./docs/deployment/nginx.default.conf.example:/etc/nginx/conf.d/default.conf:ro
@@ -0,0 +1,36 @@
1
+ server {
2
+ listen 80;
3
+ server_name _;
4
+
5
+ # Build output served directly by nginx
6
+ root /app/public;
7
+ index pages/home.html;
8
+
9
+ # API and dynamic routes handled by VanillaJet backend
10
+ location /api/ {
11
+ proxy_pass http://app:8080;
12
+ proxy_http_version 1.1;
13
+ proxy_set_header Host $host;
14
+ proxy_set_header X-Real-IP $remote_addr;
15
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16
+ proxy_set_header X-Forwarded-Proto $scheme;
17
+ }
18
+
19
+ # Static assets with long cache
20
+ location ~* \.(?:css|js|png|jpg|jpeg|gif|svg|webp|ico|ttf|otf|woff|woff2)$ {
21
+ try_files $uri =404;
22
+ expires 30d;
23
+ add_header Cache-Control "public, max-age=2592000, immutable";
24
+ }
25
+
26
+ # HTML should revalidate frequently
27
+ location ~* \.html$ {
28
+ try_files $uri =404;
29
+ add_header Cache-Control "no-cache, must-revalidate";
30
+ }
31
+
32
+ # SPA fallback to main page
33
+ location / {
34
+ try_files $uri $uri/ /pages/home.html;
35
+ }
36
+ }