builds.rst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 bundles containing the
  18. core JavaScript code and all of the 3rd party dependencies.
  19. Similarly, we use `Sass <http://sass-lang.com/>`_ to generate the CSS bundle
  20. from ``.scss`` files in the ``sass`` directory.
  21. The generated JavaScript bundles are contained in the `dist <https://github.com/conversejs/converse.js/tree/master/dist>`_ directory
  22. and the generated CSS bundles in the `css <https://github.com/conversejs/converse.js/tree/master/css>`_ directory.
  23. To generate a prticular bundle, for example the minified file ``converse.min.js``, you can run ``make dist/converse.min.js``.
  24. This is also true for any of the other bundle files.
  25. To generate all CSS and JavaScript bundles, you can run ``make dist``.
  26. When you're developing, and constantly changing code, you can run ``make watch``
  27. to let the bundles be automatically generated as soon as you edit a file.
  28. The Converse repository does not include the minified files in the ``dist`` or
  29. ``css`` directories. Before deployment, you'll want to generate them yourself.
  30. To only generate the minified files, you can make them individually. ::
  31. make dist/converse.min.js
  32. make dist/converse.min.css
  33. .. note::
  34. If you're on Windows or don't have GNU Make installed, you can run ``npm build``
  35. to build all the distribution files.
  36. Creating custom bundles
  37. =======================
  38. One reason you might want to create your own bundles, is because you want to
  39. remove some of the core plugins of Converse, or perhaps you want to include
  40. your own.
  41. To add or remove plugins from the build, you need to modify the
  42. `src/converse.js <https://github.com/conversejs/converse.js/blob/master/src/converse.js>`_ file.
  43. You'll find a section marked ``/* START: Removable components`` and
  44. ``/* END: Removable components */``.
  45. In this section is listed the Converse plugins that will make up a bundle.
  46. You could for example decide to disable the ControlBox altogether by removing
  47. the ``converse-controlbox`` plugin.
  48. After doing so, you need to run ``make dist`` again in the root or your
  49. Converse repository, in order to generate the new build.
  50. Be aware that some plugins might have dependencies on other plugins, so if you
  51. remove a certain plugin but other included plugins still depend on it, then it
  52. will still be included in your build.
  53. To see which other plugins a particular plugin depends on, open it up in your
  54. text editor and look at the list specified as the second parameter to the
  55. ``define`` call, near the top of the file. This list specifies the dependencies
  56. of that plugin.
  57. Besides the standard build, the Converse repository includes configuration
  58. for certain other non-standard builds, which we'll now mention below.
  59. Excluding all 3rd party dependencies
  60. ------------------------------------
  61. The ``dist/converse-no-dependencies.js`` bundle contains only the core Converse
  62. code and none of the 3rd party dependencies. This might be useful if you need
  63. to load the dependencies separately.
  64. To generate this bundle, you can run:
  65. ::
  66. make dist/converse-no-dependencies.js
  67. make dist/converse-no-dependencies.min.js
  68. Headless build
  69. --------------
  70. Converse also has a special build called the `headless build`.
  71. You can generate it by running ``make dist/converse-headless.js``
  72. The headless build is a bundle of all the non-UI parts of Converse, and its aim
  73. is to provide you with an XMPP library (and application) on which you can build
  74. your own UI.
  75. It's also installable as `@converse/headless <https://www.npmjs.com/package/@converse/headless>`_.
  76. The main distribution of Converse relies on the headless build.
  77. The file `src/headless/headless.js <https://github.com/jcbrand/converse.js/blob/master/src/headless/headless.js>`_
  78. is used to determine which plugins are included in the build.