Skip to content

replace

The replace preprocess module walks a directory and rewrites files before Turna starts the server and services.

yaml
preprocess:
  - replace:
      path: ./dist
      skip_dirs:
        - ./dist/assets
      contents:
        - old: __API_URL__
          new: https://api.example.com
        - regex: "version: .*"
          new: "version: 2026.05"

Fields

FieldDescription
pathRoot directory to walk.
skip_dirsExact directory paths to skip.
skip_filesFile paths recognized by the walker. Prefer narrowing path or using skip_dirs for reliable exclusion.
contentsReplacement rules applied to each visited file.

Replacement rule fields:

FieldDescription
regexRegular expression to replace. When set, it overrides old.
oldLiteral string to replace.
old_templateRender old as a Turna template before replacement.
newReplacement string.
new_templateRender new as a Turna template before replacement.
valueName of a loaded map[string]any. Each map key is replaced by its value.

Loaded Values Example

yaml
loads:
  - name: frontend_env
    statics:
      - content:
          name: frontend_env
          content: |
            __API_URL__: https://api.example.com
            __APP_NAME__: turna

preprocess:
  - replace:
      path: ./dist
      contents:
        - value: frontend_env

This is useful for frontend builds that contain placeholder strings and need platform-specific values at runtime.