build-preview-ui.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>Build a UI Project for Local Preview :: jMonkeyEngine Docs</title>
  7. <link rel="canonical" href="https://wiki.jmonkeyengine.org/wiki-ui/build-preview-ui.html">
  8. <link rel="prev" href="set-up-project.html">
  9. <link rel="next" href="development-workflow.html">
  10. <meta name="generator" content="Antora 3.0.1">
  11. <link rel="stylesheet" href="../_/css/site.css">
  12. <meta property="og:image" content="https://wiki.jmonkeyengine.org/_/img/iconx128.png">
  13. <meta property="og:description" content="Build a UI Project for Local Preview">
  14. <meta property="og:title" content="jMonkeyEngine Docs">
  15. <link rel="stylesheet" href="../_/css/site-extra.css">
  16. <link rel="stylesheet" href="../_/css/vendor/docsearch.min.css">
  17. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css -->
  18. <link rel="icon" href="../_/img/favicon.ico" type="image/x-icon">
  19. </head>
  20. <body class="article">
  21. <header class="header">
  22. <nav class="navbar">
  23. <div class="navbar-brand">
  24. <a class="navbar-item" href="https://wiki.jmonkeyengine.org">
  25. <img alt="" src="../_/img/jme-logo.png" height="32" type="image/x-icon">
  26. </a>
  27. <div class="navbar-item hide-for-print">
  28. <input id="search-input" type="text" placeholder="Search docs">
  29. </div>
  30. <button class="navbar-burger" data-target="topbar-nav">
  31. <span></span>
  32. <span></span>
  33. <span></span>
  34. </button>
  35. </div>
  36. <div id="topbar-nav" class="navbar-menu">
  37. <div class="navbar-end">
  38. <div class="navbar-item theme-switch-wrapper">
  39. <label class="theme-switch" for="checkbox">
  40. <input type="checkbox" id="checkbox" />
  41. <div class="slider round"></div>
  42. </label>
  43. </div>
  44. <a class="navbar-item" href="https://github.com/jmonkeyengine/wiki">Github</a>
  45. </div>
  46. </div>
  47. </nav>
  48. </header>
  49. <div class="body">
  50. <div class="nav-container" data-component="wiki-ui" data-version="master">
  51. <aside class="nav">
  52. <div class="panels">
  53. <div class="nav-panel-menu is-active" data-panel="menu">
  54. <nav class="nav-menu">
  55. <h3 class="title"><a href="index.html">Wiki UI</a></h3>
  56. <ul class="nav-list">
  57. <li class="nav-item" data-depth="0">
  58. <ul class="nav-list">
  59. <li class="nav-item" data-depth="1">
  60. <a class="nav-link" href="prerequisites.html">UI Development Prerequisites</a>
  61. </li>
  62. <li class="nav-item" data-depth="1">
  63. <a class="nav-link" href="set-up-project.html">Set up a UI Project</a>
  64. </li>
  65. <li class="nav-item is-current-page" data-depth="1">
  66. <a class="nav-link" href="build-preview-ui.html">Build and Preview the UI</a>
  67. </li>
  68. <li class="nav-item" data-depth="1">
  69. <a class="nav-link" href="development-workflow.html">UI Development Workflow</a>
  70. </li>
  71. <li class="nav-item" data-depth="1">
  72. <a class="nav-link" href="templates.html">Work with the Handlebars Templates</a>
  73. </li>
  74. <li class="nav-item" data-depth="1">
  75. <button class="nav-item-toggle"></button>
  76. <a class="nav-link" href="stylesheets.html">Work with the CSS Stylesheets</a>
  77. <ul class="nav-list">
  78. <li class="nav-item" data-depth="2">
  79. <a class="nav-link" href="add-fonts.html">Add Fonts</a>
  80. </li>
  81. </ul>
  82. </li>
  83. <li class="nav-item" data-depth="1">
  84. <button class="nav-item-toggle"></button>
  85. <a class="nav-link" href="style-guide.html">UI Element Styles</a>
  86. <ul class="nav-list">
  87. <li class="nav-item" data-depth="2">
  88. <a class="nav-link" href="inline-text-styles.html">Inline Text</a>
  89. </li>
  90. <li class="nav-item" data-depth="2">
  91. <a class="nav-link" href="admonition-styles.html">Admonitions</a>
  92. </li>
  93. <li class="nav-item" data-depth="2">
  94. <a class="nav-link" href="list-styles.html">Lists</a>
  95. </li>
  96. <li class="nav-item" data-depth="2">
  97. <a class="nav-link" href="sidebar-styles.html">Sidebars</a>
  98. </li>
  99. <li class="nav-item" data-depth="2">
  100. <a class="nav-link" href="ui-macro-styles.html">UI Macros</a>
  101. </li>
  102. </ul>
  103. </li>
  104. </ul>
  105. </li>
  106. </ul>
  107. </nav>
  108. </div>
  109. <div class="nav-panel-explore" data-panel="explore">
  110. <div class="context">
  111. <span class="title">Wiki UI</span>
  112. <span class="version">master</span>
  113. </div>
  114. <ul class="components">
  115. <li class="component">
  116. <span class="title">JME</span>
  117. <ul class="versions">
  118. <li class="version">
  119. <a href="../docs/3.8/documentation.html">3.8</a>
  120. </li>
  121. <li class="version">
  122. <a href="../docs/3.4/documentation.html">3.4</a>
  123. </li>
  124. <li class="version">
  125. <a href="../docs/3.3/documentation.html">3.3</a>
  126. </li>
  127. <li class="version">
  128. <a href="../docs/3.2/documentation.html">3.2</a>
  129. </li>
  130. </ul>
  131. </li>
  132. <li class="component">
  133. <span class="title">Wiki Contribution</span>
  134. <ul class="versions">
  135. <li class="version">
  136. <a href="../docs-wiki/3.8/wiki_contributor.html">3.8</a>
  137. </li>
  138. </ul>
  139. </li>
  140. <li class="component is-current">
  141. <span class="title">Wiki UI</span>
  142. <ul class="versions">
  143. <li class="version is-current">
  144. <a href="index.html">master</a>
  145. </li>
  146. </ul>
  147. </li>
  148. </ul>
  149. </div>
  150. </div>
  151. </aside>
  152. </div>
  153. <main class="article">
  154. <div class="toolbar" role="navigation">
  155. <button class="nav-toggle"></button>
  156. <nav class="breadcrumbs" aria-label="breadcrumbs">
  157. <ul>
  158. <li><a href="index.html">Wiki UI</a></li>
  159. <li><a href="build-preview-ui.html">Build and Preview the UI</a></li>
  160. </ul>
  161. </nav>
  162. <div class="edit-this-page"><a href="https://github.com/jMonkeyEngine/wiki-ui/edit/master/docs/modules/ROOT/pages/build-preview-ui.adoc">Edit this Page</a></div>
  163. </div>
  164. <div class="content">
  165. <article class="doc">
  166. <h1 class="page">Build a UI Project for Local Preview</h1>
  167. <div class="sect1">
  168. <h2 id="build-preview-site"><a class="anchor" href="#build-preview-site"></a>Build Preview Site</h2>
  169. <div class="sectionbody">
  170. <div class="paragraph">
  171. <p>Once you&#8217;ve modified the site UI, the first thing you&#8217;ll want to do is check out how it looks.
  172. That&#8217;s what the files in the <em class="path">preview-src/</em> folder are for.
  173. This folder contains HTML file fragments that provide a representative sample of content from the site.
  174. The preview saves you from having to generate the whole site just to test the UI.
  175. These files should give you an idea of how the UI will look when applied to the actual site.</p>
  176. </div>
  177. <div class="paragraph">
  178. <p>The pages in the preview site are assembled using the Handlebars templates and link to the pre-compiled asset files (emulating the behavior of the site generator).
  179. Thus, to look at them, you need to run them through the UI build.</p>
  180. </div>
  181. <div class="paragraph">
  182. <p>There are two preview modes available.
  183. You can run the build once and examine the result or you can run the build continuously so you can see changes as you make them.
  184. The next two sections explain how to use these modes.</p>
  185. </div>
  186. <div class="sect2">
  187. <h3 id="build-once"><a class="anchor" href="#build-once"></a>Build Once</h3>
  188. <div class="paragraph">
  189. <p>To build the UI once for preview, then stop, execute the following command:</p>
  190. </div>
  191. <div class="literalblock">
  192. <div class="content">
  193. <pre>$ gulp preview:build</pre>
  194. </div>
  195. </div>
  196. <div class="paragraph">
  197. <p>This task pre-compiles the UI files into the <em class="path">public</em> directory.
  198. To view the preview pages, navigate to the HTML pages in the <em class="path">public</em> directory using your browser (e.g., <em class="path">public/index.html</em>).</p>
  199. </div>
  200. </div>
  201. <div class="sect2">
  202. <h3 id="build-continuously"><a class="anchor" href="#build-continuously"></a>Build Continuously</h3>
  203. <div class="paragraph">
  204. <p>To avoid the need to run the <code>preview:build</code> task over and over while developing, you can use the <code>preview</code> command instead to have it run continuously.
  205. This task also launches a local HTTP server so updates get synchronized with the browser (i.e., &#8220;live reload&#8221;).</p>
  206. </div>
  207. <div class="paragraph">
  208. <p>To launch the preview server, execute the following command:</p>
  209. </div>
  210. <div class="literalblock">
  211. <div class="content">
  212. <pre>$ gulp preview</pre>
  213. </div>
  214. </div>
  215. <div class="paragraph">
  216. <p>You&#8217;ll see a URL listed in the output of this command:</p>
  217. </div>
  218. <div class="literalblock">
  219. <div class="content">
  220. <pre>[12:59:28] Starting 'preview:serve'...
  221. [12:59:28] Starting server...
  222. [12:59:28] Server started http://localhost:5252
  223. [12:59:28] Running server</pre>
  224. </div>
  225. </div>
  226. <div class="paragraph">
  227. <p>Navigate to the URL to view the preview site.
  228. While this command is running, any changes you make to the source files will be instantly reflected in the browser.
  229. This works by monitoring the project for changes, running the <code>preview:build</code> task if a change is detected, and sending the updates to the browser.</p>
  230. </div>
  231. <div class="paragraph">
  232. <p>Press <span class="keyseq"><kbd>Ctrl</kbd>+<kbd>C</kbd></span> to stop the preview server and end the continuous build.</p>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="sect1">
  238. <h2 id="package-for-previewing"><a class="anchor" href="#package-for-previewing"></a>Package for Previewing</h2>
  239. <div class="sectionbody">
  240. <div class="paragraph">
  241. <p>If you need to bundle the UI in order to preview the UI on the real site in local development, run the following command:</p>
  242. </div>
  243. <div class="literalblock">
  244. <div class="content">
  245. <pre>$ gulp bundle</pre>
  246. </div>
  247. </div>
  248. <div class="paragraph">
  249. <p>The <code>bundle</code> command also invokes the <code>lint</code> command to check that the CSS and JavaScript follow the coding standards.</p>
  250. </div>
  251. <div class="paragraph">
  252. <p>The UI bundle will be available at <em class="path">build/ui-bundle.zip</em>.
  253. You can then point Antora at this bundle using the <code>--ui-bundle-url</code> command-line option.</p>
  254. </div>
  255. <div class="paragraph">
  256. <p>If you have the preview running, and you want to bundle without causing the preview to be clobbered, use:</p>
  257. </div>
  258. <div class="literalblock">
  259. <div class="content">
  260. <pre>$ gulp bundle:pack</pre>
  261. </div>
  262. </div>
  263. <div class="paragraph">
  264. <p>The UI bundle will again be available at <em class="path">build/ui-bundle.zip</em>.</p>
  265. </div>
  266. </div>
  267. </div>
  268. <nav class="pagination">
  269. <span class="prev"><a href="set-up-project.html">Set up a UI Project</a></span>
  270. <span class="next"><a href="development-workflow.html">UI Development Workflow</a></span>
  271. </nav>
  272. </article>
  273. <aside class="toc sidebar" data-title="Contents" data-levels="2">
  274. <div class="toc-menu"></div>
  275. </aside>
  276. </div>
  277. </main>
  278. </div>
  279. <footer class="footer">
  280. <p>Copyright 2020 jMonkeyEngine Wiki Contributors. Licensed BSD-3.</p>
  281. </footer>
  282. <script src="../_/js/vendor/docsearch.min.js"></script>
  283. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js -->
  284. <script>
  285. var search = docsearch({
  286. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  287. indexName: 'jmonkeyengine',
  288. inputSelector: '#search-input',
  289. autocompleteOptions: { hint: false, keyboardShortcuts: ['s'] },
  290. algoliaOptions: { hitsPerPage: 10 }
  291. }).autocomplete
  292. search.on('autocomplete:closed', function () { search.autocomplete.setVal() })
  293. function focusSearchInput () { document.querySelector('#search-input').focus() }
  294. if (document.querySelector('.home-link.is-current')) window.addEventListener('load', focusSearchInput)
  295. </script>
  296. <script src="../_/js/site.js"></script>
  297. <script async src="../_/js/vendor/highlight.js"></script>
  298. </body>
  299. </html>