Vite build breaks mechanism to provide extra resources for the editor

When building a widget for Dashboard-2, vite places the resulting file into the /resources folder:

Unfortunately, as it's documentation states,

by default, Vite will empty the outDir on build if it is inside project root.

This is unfortunate, as it deletes as well all (other) files existing in /resources, thus breaking the mechanism to provide additional files to load into the editor as extra resources.

I've created a PR to fix this issue:

  • Rather than building directly into /resources, vite shall build into ui/dist directory.
  • The resulting file will then be copied into /resources.
  • The operation will be performed by vite-plugin-static-copy, added as dev-dependency.
  • To compensate for an error when trying to require an ESM only module, vite.config.js has to be renamed to vite.config.mjs.
  • Took the opportunity to fix as well the repo path in package.json, still pointing to a flowforge repo, non-existing.
1 Like

Thanks for much for the detailed report and PR. Had missed entirely the fact that the resources folder would be emptied by vite.

Have commented on the PR with some thoughts.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.