builds.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .. raw:: html
  2. <div id="banner"><a href="https://github.com/jcbrand/converse.js/blob/master/docs/source/builds.rst">Edit me on GitHub</a></div>
  3. .. _builds:
  4. =================
  5. Generating builds
  6. =================
  7. .. contents:: Table of Contents
  8. :depth: 3
  9. :local:
  10. .. warning:: There current documentation in this section does not adequately
  11. explain how to create custom bundles.
  12. .. Note:: Please make sure to read the section :doc:`development` and that you have installed
  13. all development dependencies (long story short, you should be able to just run ``make dev``)
  14. .. _creating_builds:
  15. Creating JavaScript and CSS bundles and distribution files
  16. ==========================================================
  17. Converse uses `webpack <https://webpack.js.org/>`_ to create the final JavaScript and CSS distribution files.
  18. The generated distribution files are all placed in the ``./dist`` directory.
  19. The Converse repository does not include ``dist`` directory by default.
  20. To generate the ``./dist`` directory and all CSS and JavaScript bundles, simply run ``make dist``.
  21. When you're developing, and constantly changing code, you can run ``make watch``
  22. to let the bundles be automatically generated as soon as you edit a file.
  23. .. note::
  24. If you're on Windows or don't have GNU Make installed, you can run ``npm build``
  25. to build all the distribution files.
  26. Creating custom bundles
  27. =======================
  28. One reason you might want to create your own bundles, is because you want to
  29. remove some of the core plugins of Converse, or perhaps you want to include
  30. your own.
  31. To add or remove plugins from the build, you need to modify
  32. `src/index.js <https://github.com/conversejs/converse.js/blob/master/src/index.js>`_ or
  33. `src/headless/index.js <https://github.com/conversejs/converse.js/blob/master/src/index.js>`_.
  34. You'll find a section marked ``/* START: Removable components`` and
  35. ``/* END: Removable components */``.
  36. In this section is listed the Converse plugins that will make up a bundle.
  37. You could for example decide to disable the ControlBox altogether by removing
  38. the ``converse-controlbox`` plugin.
  39. After doing so, you need to run ``make dist`` again in the root or your
  40. Converse repository, in order to generate the new build.
  41. Be aware that some plugins might have dependencies on other plugins, so if you
  42. remove a certain plugin but other included plugins still depend on it, then it
  43. will still be included in your build.
  44. To see which other plugins a particular plugin depends on, open it up in your
  45. text editor and look at the list specified as the second parameter to the
  46. ``define`` call, near the top of the file. This list specifies the dependencies
  47. of that plugin.
  48. Besides the standard build, the Converse repository includes configuration
  49. for certain other non-standard builds, which we'll now mention below.
  50. Excluding all 3rd party dependencies
  51. ------------------------------------
  52. The ``dist/converse-no-dependencies.js`` bundle contains only the core Converse
  53. code and none of the 3rd party dependencies. This might be useful if you need
  54. to load the dependencies separately.
  55. To generate this bundle, you can run:
  56. ::
  57. make dist/converse-no-dependencies.js
  58. make dist/converse-no-dependencies.min.js
  59. Headless build
  60. --------------
  61. Converse also has a special build called the `headless build`.
  62. You can generate it by running ``make dist/converse-headless.js``
  63. The headless build is a bundle of all the non-UI parts of Converse, and its aim
  64. is to provide you with an XMPP library (and application) on which you can build
  65. your own UI.
  66. It's also installable as `@converse/headless <https://www.npmjs.com/package/@converse/headless>`_.
  67. The main distribution of Converse relies on the headless build.
  68. The file `src/headless/headless.js <https://github.com/jcbrand/converse.js/blob/master/src/headless/headless.js>`_
  69. is used to determine which plugins are included in the build.