Development
Here we'll cover a few common tasks developers might face when setting up formBuilder. See Contributing for the full list of npm scripts, git hooks and commit message conventions.
Requirements
Node.js ^20.19.0 or >=22.12.0 and npm. The build uses Vite, tests use Vitest and linting uses ESLint, all installed as dev dependencies.
Clone the repo
$ git clone [email protected]:kevinchappell/formBuilder.git form-builder && cd form-builderInstall Dependencies
$ npm installLocal development
Once you've cloned the project and installed its dependencies you can get a local version running by running:
$ npm startThis builds demo/assets/js/vendor.js, copies the language files to demo/assets/lang and starts a Vite dev server with vite.config.demo.js that serves the demo page from src/demo. Vite prints the local URL in the terminal. The demo loads formBuilder and formRender straight from src/js, so changes show up without a rebuild. This demo can be used to test features and bugs.
Build
$ npm run buildBuilds form-builder and form-render as minified and unminified UMD bundles in /dist using vite.config.lib.js (shared settings live in vite.config.base.js) and gzips them. The SCSS in src/sass is compiled by Vite and injected into the JS bundles, so there is no separate CSS file.
$ npm run build:demoBuilds the demo page for production with vite.config.demo.js. It writes demo/index.html and the demo's own assets (demo/assets/js/demo.min.js and its CSS in demo/assets/css). The built page loads vendor.js, form-builder.min.js and form-render.min.js from demo/assets/js, so run it after build, build:vendor and copy, or just use build:all.
$ npm run build:allRuns build:plugins, build:vendor, build, copy and build:demo in sequence. On top of build this builds the control plugins to dist/control_plugins (npm run build:plugins), the demo's vendor.js (npm run build:vendor), copies the build output, language files, CONTRIBUTING.md and LICENSE into the demo and docs (npm run copy) and builds the demo page (npm run build:demo). The result in demo/ is a complete static site.
Demo deployment
The Deploy Demo workflow runs on every push to master. It runs npm run build:all and publishes the demo/ directory to the gh-pages branch, which GitHub Pages serves at https://kevinchappell.github.io/formBuilder/. demo/ is ignored by git, so don't commit it.
Tests and Linting
$ npm test # Vitest with coverage
$ npm run lint # ESLint on src/, reports problems without failing
$ npm run lint:fix # ESLint on src/ with automatic fixesESLint is configured in eslint.config.mjs and Prettier in .prettierrc.json.
Documentation
These docs, like the rest of the website at formbuilder.online, are built with VitePress from the docs directory of the separate kevinchappell/formBuilder-site repository, not from the formBuilder plugin repo. The sidebar is generated from the nav section of that repository's mkdocs.yml. From the formBuilder-site repo:
$ npm ci
$ npm run dev:docs # VitePress dev server with live reload for files under docs/
$ npm run build:docs # builds the docs into public/docsThe formBuilder plugin repo also has its own docs directory, built with MkDocs. npm run docs in the plugin repo builds a Docker image (npm run docs:build) and serves those docs on port 8123 (npm run docs:serve).
Languages
At the time of writing this, formBuilder is available in dozens of languages thanks to generous contributors around the world. If you would like to contribute, formBuilder's language repo can be found here.
Only the en-US strings are bundled with formBuilder. Other languages are loaded at runtime from i18n.location, which defaults to the relative path assets/lang/, so a de-DE locale is fetched from assets/lang/de-DE.lang relative to the page. Either copy the .lang files from the formbuilder-languages npm package to that path on your server or set i18n.location, for example to the jsDelivr CDN:
$(container).formBuilder({
i18n: {
locale: 'de-DE',
location: 'https://cdn.jsdelivr.net/npm/[email protected]/',
},
})See the i18n option for all settings.
Custom Controls
See the Control and Control Plugin Architecture Documentation to learn about how to create custom controls.