builds.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 css/converse.min.css
  33. Creating custom bundles
  34. =======================
  35. One reason you might want to create your own bundles, is because you want to
  36. remove some of the core plugins of Converse, or perhaps you want to include
  37. your own.
  38. To add or remove plugins from the build, you need to modify the
  39. `src/converse.js <https://github.com/conversejs/converse.js/blob/master/src/converse.js>`_ file.
  40. You'll find a section marked ``/* START: Removable components`` and
  41. ``/* END: Removable components */``.
  42. In this section is listed the Converse plugins that will make up a bundle.
  43. You could for example decide to disable the ControlBox altogether by removing
  44. the ``converse-controlbox`` plugin.
  45. After doing so, you need to run ``make dist`` again in the root or your
  46. Converse repository, in order to generate the new build.
  47. Be aware that some plugins might have dependencies on other plugins, so if you
  48. remove a certain plugin but other included plugins still depend on it, then it
  49. will still be included in your build.
  50. To see which other plugins a particular plugin depends on, open it up in your
  51. text editor and look at the list specified as the second parameter to the
  52. ``define`` call, near the top of the file. This list specifies the dependencies
  53. of that plugin.
  54. Besides the standard build, the Converse repository includes configuration
  55. for certain other non-standard builds, which we'll now mention below.
  56. Excluding all 3rd party dependencies
  57. ------------------------------------
  58. The ``dist/converse-no-dependencies.js`` bundle contains only the core Converse
  59. code and none of the 3rd party dependencies. This might be useful if you need
  60. to load the dependencies separately.
  61. To generate this bundle, you can run:
  62. ::
  63. make dist/converse-no-dependencies.js
  64. make dist/converse-no-dependencies.min.js
  65. Headless build
  66. --------------
  67. Converse also has a special build called the `headless build`.
  68. You can generate it by running ``make dist/converse-headless.js``
  69. The headless build is a bundle of all the non-UI parts of Converse, and its aim
  70. is to provide you with an XMPP library (and application) on which you can build
  71. your own UI.
  72. It's also installable as `@converse/headless <https://www.npmjs.com/package/@converse/headless>`_.
  73. The main distribution of Converse relies on the headless build.
  74. The file `src/headless/headless.js <https://github.com/jcbrand/converse.js/blob/master/src/headless/headless.js>`_
  75. is used to determine which plugins are included in the build.