shacl-vue/docs/build-configuration.md
Stephan Heunis c581edb29c
All checks were successful
Deploy on webserver / Build docs and deploy (push) Successful in 45s
Build shacl-vue / build (push) Successful in 51s
Factor out markdown rendering and add config error dialog
These changes were prompted by the need to show an error message when shacl-vue
fails to load the specified config file correctly. Such an error message would
ideally be configurable, with markdown support. Adding markdown support to a new
dialog in the 'ShaclVue' component highlighted the fact that markdown functionality
was already duplicated across the 'MarkdownEditor' and the 'WizardEditor' components.

This was factored out by doing the following:
- creating a 'useMarkdown' composable with the common functionality, and using this
  in 'ShaclVue', 'MarkdownEditor', and 'WizardEditor'
- moving common css, specifically the 'markdown-render' class, into
  'src/assets/style.css', which can now be used anywhere in the app

Then, the configuration composable was updated to load a config error message from the
new build-time configuration option CONFIG_ERROR_TEXT. A build-time config is necessary
here because the nature of the config error means that a normal runtime config option
won't be available to be displayed. The CONFIG_ERROR_TEXT option has to be supplied via
the config yaml file, which is passed via the BUILD_CONFIG='path/to/config/file.yaml'
option supplied at build time.

If this build-time config option is not supplied, the config error message defaults to:
'
  There was a problem loading the configuraton source.
  Please reload the page, or contact the site administrator if the problem persists.
'

This new error will show up in a dialog when a user opens shacl-vue in their browser, if:
- the main config URL cannot be fetched successfully
- the external config URL cannot be fetched successfully
2026-11-10 22:31:33 +02:00

3.4 KiB

layout
doc

Build configuration

shacl-vue supports the use of build-time configuration options that are supplied either directly as ENV variables or via a config file, for example:

BUILD_GIT_COMMIT="$(shell git rev-parse HEAD)" npm run build:app

or

BUILD_CONFIG='path/to/config/file.yaml' npm run build:app

The latter allows the specification of config options at build time via a path to a JSON or YAML file, using the BUILD_CONFIG environment variable. The file is read by Vite at build time and injected into environment variables that are made accessible to the rest of the application in the standard Vite approach, i.e. via import.meta.env.VITE_MY_VARIABLE in Javascript/VueJS files and %VITE_MY_VARIABLE% in HTML. Note that variables specified via such a build config file are not required to have the VITE_ prefix.

Currently supported build variables are described below in sections:

Build environment details

BUILD_CONFIG

A path to a build-environment-local JSON or YAML file that contains build configuration variables.

BUILD_GIT_*

For easier status checks and debugging, shacl-vue UI can display the specifics of a git repository used during the build process. This is shown in the Settings dialog, for example:

alt

To allow this, four environment variables should be accessible to the build process:

  • BUILD_GIT_COMMIT: The git commit hash of the git repository when the UI was built
  • BUILD_GIT_COMMIT_SHORT: The short version of the commit hash of the git repository when the UI was built
  • BUILD_GIT_BRANCH: The branch of the git repository used during the build
  • BUILD_GIT_DATE: The datetime snapshot at build time

This can be done dynamically at build time, e.g.:

BUILD_GIT_COMMIT="$(shell git rev-parse HEAD)" \
BUILD_GIT_COMMIT_SHORT="$(shell git rev-parse --short HEAD)" \
BUILD_GIT_BRANCH="$(shell git rev-parse --abbrev-ref HEAD)" \
BUILD_GIT_DATE="$(shell git show -s --format=%cI HEAD)" npm run build:app

Build outputs

VITE_OUT_DIR

A local path can be provided to specify where the build output files should be saved.

UI specifications

VITE_SHACLVUE_VARIANT

This can be used to specify of the default or starter variant of the UI should be build. See the shacl-vue Kickstarter variant section for more information.

CONFIG_ERROR_TEXT

The message to show in an error dialog when, at startup, a shacl-vue instance is unable to:

  • fetch the main config URL, or
  • fetch the external config URL

For example:

CONFIG_ERROR_TEXT: >-
  There was a problem loading the configuraton source.
  Please reload the page, or contact the site administrator if the problem persists.

will lead to the following dialog being displayed:

alt

The text shown above is also the default config error message, if the CONFIG_ERROR_TEXT option is unspecified.

Security specifications

Some browser-side security features of shacl-vue can be configured via build config options, including:

  • DOMPURIFY
  • CSP_CONTENT
  • FETCH

See the Security features section for a detailed specification.