builds.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Creating 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 builds.
  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 and distribution files
  15. ======================================
  16. Converse.js uses `AMD (Asynchronous Modules Definition) <http://requirejs.org/docs/whyamd.html#amd>`_
  17. to define modules and their dependencies.
  18. Dependencies can then be loaded on-the-fly with `require.js <http://requirejs.org>`_.
  19. This is very useful during development, but when it comes to
  20. deployement you'll usually want to create a single, minified distribution build.
  21. For this, the `r.js optimizer <http://requirejs.org/docs/optimization.html>`_
  22. is used together with `almond.js <https://github.com/requirejs/almond>`_, which
  23. is a smaller and minimal AMD API implementation that replaces require.js in builds.
  24. To create the distribution builds, simply run::
  25. make dist
  26. This command does the following:
  27. * It creates different builds of Converse.js in the ``./dist/`` directory.
  28. * It bundles all the translation files in ``./locale/`` into a single file ``locales.js``.
  29. This file can then be included via the ``<script>`` tag. See for example the ``non_amd.html`` example page.
  30. * Also, the CSS files in the ``./css`` directory will be minified.
  31. The JavaScript build files are contained in the ``./dist`` directory:
  32. .. code-block:: bash
  33. jc@conversejs:~/converse.js (master)$ ls dist/
  34. converse-mobile.js converse.min.js
  35. converse-mobile.min.js converse.nojquery.js
  36. converse-no-dependencies.js converse.nojquery.min.js
  37. converse-no-dependencies.min.js locales.js
  38. converse.js
  39. .. _`minification`:
  40. Creating custom builds
  41. ----------------------
  42. One reason you might want to create your own builds, is because you want to
  43. remove some of the core plugins of converse.js, or perhaps you want to include
  44. your own.
  45. To add or remove plugins from the build, you need to modify the
  46. ``src/converse.js`` file.
  47. You'll find a section marked ``/* START: Removable components`` and
  48. ``/* END: Removable components */``.
  49. In this section is listed all the converse.js plugins that will make up a
  50. build.
  51. You could for example decide to disable the ControlBox altogether by removing
  52. the ``converse-controlbox`` plugin.
  53. After doing so, you need to run ``make dist`` again in the root or your
  54. converse.js repository, in order to generate the new build.
  55. Be aware that some plugins might have dependencies on other plugins, so if you
  56. remove a certain plugin but other included plugins still depend on it, then it
  57. will still be included in your build.
  58. To see which other plugins a particular plugin depends on, open it up in your
  59. text editor and look at the list specified as the second parameter to the
  60. ``define`` call, near the top of the file. This list specifies the dependencies
  61. of that plugin.
  62. Minifying the CSS
  63. -----------------
  64. To only minify the CSS files, nothing else, run the following command::
  65. make cssmin
  66. The CSS files are minified via `cssmin <https://github.com/gruntjs/grunt-contrib-cssmin>`_.