BlogTroubleshootingBuild

Vendra styles, images or scripts do not load after moving the files, or the build fails

Relative paths and what breaks them, the Content Security Policy that blocks inline scripts and outside resources, the React edition in a sub-folder, and the usual causes of a failed npm run build or npm test.

4 min readPerforks

A page moved to a sub-folder with its relative paths broken, and the Content Security Policy that blocks inline scripts

A page is unstyled, or images and fonts are missing

The built pages link their assets with paths relative to the page: ./assets/css/vendra.min.css, ./assets/img/products/…, and the fonts from ../fonts/ inside the stylesheet. That is what lets dist/ work from disk and from any folder on a host. It also means:

  • Move the whole dist/ folder, never a page on its own. A page copied out of the folder has no assets/ next to it.
  • Keep pages and assets/ at the same level. Putting pages in a sub-folder (/shop/index.html) breaks every ./assets/ link unless you move assets/ with them or rewrite the paths.
  • If you serve the pages through a template or a CMS, src/partials/head.hbs and scripts.hbs are where the links are made; adjust them there and rebuild rather than editing dist/ by hand.

After an upload, a hard refresh is not needed: the build adds a ?v= query to every asset link, so a new build is never served from the old cache.

A script I added does not run, or an outside image or font does not load

Every built page carries a Content Security Policy meta tag. It allows scripts, styles, images, fonts and connections from the page's own origin only, plus the hashes of the inline scripts the build itself generated, data: URLs for fonts and images, and https://www.openstreetmap.org in frames for the map embeds. The browser reports what it blocks in the console as a policy violation.

  • An inline <script> you added to a page in src/ is hashed automatically at build time, so it runs. The same script pasted into a page in dist/ is not, and is blocked. Edit the source and rebuild, or put the code in a file under public/ and link it.
  • Images, fonts, scripts or analytics from another domain need that domain in the policy. The policy is built in vite.config.js (the csp array in the vendraPages() plugin): add the origin to img-src, font-src, script-src or connect-src and rebuild. Inline event handlers (onclick="…") are never allowed; bind listeners in a script instead.
  • Sending the policy as a header too (the commented line in server-config/apache.htaccess) must include the same 'sha256-…' sources as the meta tag, or the inline scripts stop.
  • To build without the policy while you debug, run the build with VENDRA_CSP=off in the environment. Put it back before going live.

The React edition shows a blank page or 404s in a sub-folder

Built with the default base, the app expects to live at the root of its host and loads /assets/…. Under a sub-folder those paths point at the wrong place. Build with the folder as base, for example npx vite build --base /react/, or set base in react/vite.config.js; the router reads the same value for its own paths. And configure the host to answer unknown paths with index.html (on nginx try_files $uri /index.html;), or a reload on /shop is a 404.

npm run build fails

  1. Node version. Vendra needs Node.js 20 or newer; check with node -v. Older versions fail on syntax or on the Vite version in package.json.
  2. Dependencies not installed. Run npm install in the folder that holds package.json. For the React edition, install in the parent folder first and then in react/: it resolves Bootstrap and the engine from the parent.
  3. A Handlebars error names a page. The build assembles src/*.html with partials and helpers; a partial that does not exist, an unclosed {{#each}}, or a product helper with a demo or category that is not in catalog.js stops the build with the file name in the message.
  4. A demo key that is not in DEMOS. Setting a page's demo in pages.js to a key without an entry in DEMOS of catalog.js fails when the page context is built, because the store name is read from it.
  5. Sass warnings about deprecations are expected with Bootstrap 5.3 and are silenced in the config; they are not errors.

npm test or npm run responsive fails straight away

Both drive a real browser through Playwright. The first time, run npx playwright install chromium to download it; without that the script stops before opening a page. npm test runs against dist/, so build first. In react/, npm test builds and serves the app itself, but it also needs the Chromium download.

If none of this matches, write to [email protected] with the page, your browser or Node version, and the exact message; support covers reproducible defects in Vendra while your licence is active.