Generating Builds
Creating JavaScript and CSS bundles and distribution files
Section titled “Creating JavaScript and CSS bundles and distribution files”Converse uses RSPack to create the final JavaScript and CSS distribution files.
The generated distribution files are all placed in the ./dist directory.
The Converse repository does not include dist directory by default.
To generate the ./dist directory and all CSS and JavaScript bundles, simply run:
npm run buildWhen you’re developing, and constantly changing code, you can run:
npm run watchThis will let the bundles be automatically generated as soon as you edit a file.
Development builds
Section titled “Development builds”For development, you can use:
npm run dev- Creates unminified development buildsnpm run watch- Watches for changes and rebuilds automaticallynpm run devserver- Starts the RSPack development server with live reloading
Production builds
Section titled “Production builds”For production builds, you can use:
npm run build- Creates minified production builds (ESM and CJS)npm run build:headless- Builds the headless packagenpm run build:esm- Builds only the ESM bundlenpm run build:cjs- Builds only the CommonJS bundle
Special builds
Section titled “Special builds”Headless build
Section titled “Headless build”Converse has a special build called the headless build.
You can generate it by running:
npm run build:headlessThe headless build is a bundle of all the non-UI parts of Converse, and its aim is to provide you with an XMPP library (and application) on which you can build your own UI.
It’s also installable as @converse/headless.
The main distribution of Converse relies on the headless build.
The file src/headless/index.js is used to determine which plugins are included in the build.
CDN build
Section titled “CDN build”To create a build suitable for CDN deployment with absolute paths, run:
npm run cdnCreating custom bundles
Section titled “Creating custom bundles”One reason you might want to create your own bundles, is because you want to remove some of the core plugins of Converse, or perhaps you want to include your own.
To add or remove plugins from the build, you need to modify src/index.js or src/headless/index.js.
You’ll find sections where plugins are imported and registered. You can comment out or remove plugins you don’t need.
After doing so, you need to run npm run build again in the root of your
Converse repository, in order to generate the new build.
Be aware that some plugins might have dependencies on other plugins, so if you remove a certain plugin but other included plugins still depend on it, then it will still be included in your build.
To see which other plugins a particular plugin depends on, open it up in your text editor and look at the import statements and plugin dependencies.
Build configuration files
Section titled “Build configuration files”The RSPack build configuration files are located in the rspack/ directory:
rspack.common.js- Shared configuration used by all buildsrspack.build.js- Main production build configurationrspack.build.esm.js- ESM-specific build configurationrspack.build.cjs.js- CommonJS-specific build configurationrspack.headless.js- Headless build configurationrspack.nodeps.js- No-dependencies build configurationrspack.serve.js- Development server configuration
Output files
Section titled “Output files”After building, the following files will be generated in the dist/ directory:
converse.js- Main CommonJS bundleconverse.min.js- Minified CommonJS bundleconverse.esm.js- Main ESM bundleconverse.min.esm.js- Minified ESM bundleconverse.css- Main CSS bundleconverse.min.css- Minified CSS bundle
The headless build generates files in src/headless/dist/:
converse-headless.js- Headless CommonJS bundleconverse-headless.min.js- Minified headless CommonJS bundleconverse-headless.esm.js- Headless ESM bundleconverse-headless.min.esm.js- Minified headless ESM bundle
Thank you to our sponsors
If you'd like to sponsor this project, please visit Github, Patreon, Liberapay or contact us.