1 | # APEX Nitro Features
|
2 | Here are the main features of APEX Nitro. Some of these are activated automatically, some of them you need to activate yourself in your project configuration.
|
3 |
|
4 | ### Browser Synchronization
|
5 | This is perhaps the number one reason to use APEX Nitro. Browser synchronization allows you to see real-time changes to the application without manual refresh.
|
6 |
|
7 | When you have launched APEX Nitro, a service runs in the background and watches for any changes made to any files within your project source directory. When a change is detected, APEX Nitro recompiles the source code and injects it automatically to your APEX application through web socket technologies.
|
8 |
|
9 | ![](img/feature-browsersync.gif)
|
10 |
|
11 | ### Minification
|
12 | APEX Nitro automatically removes unnecessary characters from external files without changing the functionality. These unnecessary characters usually include white space characters, new line, comments and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute. This considerably enhances the performance due to smaller file sizes.
|
13 |
|
14 | **Example:**
|
15 | 1. `/project/src/js/app.js`
|
16 | ```javascript
|
17 | apex.server.process(
|
18 | "test", {
|
19 | x01: "test",
|
20 | pageItems: "#P1_DEPTNO,#P1_EMPNO"
|
21 | }, {
|
22 | success: function(data) {
|
23 | console.log(data);
|
24 | }
|
25 | }
|
26 | );
|
27 | ```
|
28 |
|
29 | **Compiles to:**
|
30 | 1. `/project/dist/js/app.min.js`
|
31 | ```javascript
|
32 | apex.server.process("test",{x01:"test",pageItems:"#P1_DEPTNO,#P1_EMPNO"},{success:function(e){console.log(e)}});
|
33 | ```
|
34 |
|
35 | This example has a compression ratio of 41.05%. It makes a considerable difference on large files.
|
36 |
|
37 | Because of the minification process, you are able to use the `#MIN#` substitution string in APEX when referencing your files. Example: `#APP_IMAGES#js/app#MIN#.js`
|
38 |
|
39 | ![](img/feature-minification.png)
|
40 |
|
41 | APEX Nitro does the minification automatically, but without it the reference would have to be `#APP_IMAGES#js/app.js`.
|
42 |
|
43 | ### Concatenation
|
44 | APEX Nitro automatically combines multiple source files into a single file. This reduces the number of HTTP requests to the server thereby increasing performance. In addition, referencing a single external file within an APEX app makes programming simpler.
|
45 |
|
46 | **Example:**
|
47 | 1. `/project/src/js/app1.js`
|
48 | ```javascript
|
49 | console.log(1);
|
50 | ```
|
51 |
|
52 | 2. `/project/src/js/app2.js`
|
53 | ```javascript
|
54 | console.log(2);
|
55 | ```
|
56 |
|
57 | **Compile to:**
|
58 | 1. `/project/dist/js/app.js` *(unminified)*:
|
59 | ```javascript
|
60 | console.log(1);
|
61 | console.log(2);
|
62 | ```
|
63 |
|
64 | 1. `/project/dist/js/app.min.js` *(minified)*:
|
65 | ```javascript
|
66 | console.log(1);console.log(2);
|
67 | ```
|
68 |
|
69 | Regardless of the number of source files and their file names, they are always going to be compiled as one. That makes it easy to reference in APEX. Example: `#APP_IMAGES#js/app#MIN#.js`.
|
70 |
|
71 | APEX Nitro does **not** concatenate automatically, it has to be activated in the project configuration through `apex-nitro config <project>`. When activating the concatenation, you also have to provide a name for the concatenated file.
|
72 |
|
73 | ![](img/feature-concatenation.png)
|
74 |
|
75 | ### Source Mapping
|
76 | Once CSS and JavaScript code has been minified and concatenated, it becomes difficult to identify where an error occurs in the original source file. When that happens, your browser's debugger indicates that the error is on line 1.
|
77 |
|
78 | **Example without source maps:**
|
79 | ![](img/feature-sourcemaps-1.png)
|
80 |
|
81 | Clicking on the link opens the code, and shows this mess:
|
82 | ![](img/feature-sourcemaps-2.png)
|
83 |
|
84 | It's hard to read and harder to understand. To overcome this, APEX Nitro automatically adds source maps to your code, which aid in debugging minified and concatenated files by easily tracing the code back to the original source file.
|
85 |
|
86 | **Example of Sass source maps:**
|
87 | ![](img/feature-sourcemaps-3.png)
|
88 |
|
89 | **Example of JavaScript source maps:**
|
90 | ![](img/feature-sourcemaps-4.png)
|
91 |
|
92 | ### Error Handling
|
93 | As opposed to PL/SQL being a compiled language, CSS and JavaScript are interpreted at runtime. The obvious downside of interpreted languages is that we can slip syntactically invalid code into production. APEX Nitro includes code linters that will notify the developer of syntax errors upon saving a file.
|
94 |
|
95 | **Example of a JavaScript error warning:**
|
96 | ![](img/feature-error-js.png)
|
97 |
|
98 | **Example of a CSS error warning:**
|
99 | ![](img/feature-error-css.png)
|
100 |
|
101 | When an error is raised, the source file will not be compiled. You will have to fix the error before the file is compiled and synchronized to APEX again.
|
102 |
|
103 | ### CSS Preprocessing
|
104 | A CSS preprocessor is a program that allows generation of CSS from the preprocessor's own unique syntax making the CSS structure more readable and easier to maintain. The main benefits of CSS preprocessors are to implement CSS variables, nesting and functions. APEX Nitro comes pre-wired for SASS and Less.
|
105 |
|
106 | **Example:**
|
107 | 1. `/project/src/scss/_module1.scss`
|
108 | ```
|
109 | .parent-class {
|
110 | background-color: lightblue;
|
111 |
|
112 | .child-class {
|
113 | background-color: lightpink;
|
114 | }
|
115 | }
|
116 | ```
|
117 |
|
118 | 2. `/project/src/scss/app.scss`
|
119 | ```
|
120 | @import "module1";
|
121 |
|
122 | $primary-color: lightgreen;
|
123 |
|
124 | .t-Login-region {
|
125 | background-color: $primary-color;
|
126 | }
|
127 | ```
|
128 |
|
129 | **Compiles to:**
|
130 | 1. `/project/dist/css/app.css`
|
131 | ```css
|
132 | .parent-class {
|
133 | background-color: lightblue; }
|
134 | .parent-class .child-class {
|
135 | background-color: lightpink; }
|
136 |
|
137 | .t-Login-region {
|
138 | background-color: lightgreen; }
|
139 | ```
|
140 |
|
141 | 2. `/project/dist/css/app#MIN#.css`
|
142 | ```css
|
143 | .parent-class{background-color:#add8e6}.parent-class .child-class{background-color:#ffb6c1}.t-Login-region{background-color:#90ee90}
|
144 | ```
|
145 |
|
146 | ### Auto-Prefixer
|
147 | Some CSS properties require complex knowledge of browser vendor-specific prefixes. These special CSS properties are hard to remember and can cause a lot of problems in browser compatibility.
|
148 |
|
149 | APEX Nitro comes with auto-prefixer out of the box. No longer does the developer need to remember which properties apply to Chrome vs. Firefox vs. Internet Explorer. It’s all taken care of automatically with auto-prefixing.
|
150 |
|
151 | **Example:**
|
152 | 1. `/project/src/css/app.css`
|
153 | ```css
|
154 | .example {
|
155 | display: flex;
|
156 | transition: all .5s;
|
157 | user-select: none;
|
158 | background: linear-gradient(to bottom, white, black);
|
159 | }
|
160 | ```
|
161 |
|
162 | **Compiles to:**
|
163 | 1. `/project/dist/css/app.css`
|
164 | ```css
|
165 | .example {
|
166 | display: -webkit-box;
|
167 | display: -ms-flexbox;
|
168 | display: flex;
|
169 | -webkit-transition: all .5s;
|
170 | -o-transition: all .5s;
|
171 | transition: all .5s;
|
172 | -webkit-user-select: none;
|
173 | -moz-user-select: none;
|
174 | -ms-user-select: none;
|
175 | user-select: none;
|
176 | background: -webkit-gradient(linear, left top, left bottom, from(white), to(black));
|
177 | background: -webkit-linear-gradient(top, white, black);
|
178 | background: -o-linear-gradient(top, white, black);
|
179 | background: linear-gradient(to bottom, white, black);
|
180 | }
|
181 | ```
|
182 |
|
183 | 2. `/project/dist/css/app#MIN#.css`
|
184 | ```css
|
185 | .example{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transition:all .5s;-o-transition:all .5s;transition:all .5s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:-webkit-gradient(linear,left top,left bottom,from(white),to(black));background:-webkit-linear-gradient(top,#fff,#000);background:-o-linear-gradient(top,#fff,#000);background:linear-gradient(to bottom,#fff,#000)}
|
186 | ```
|
187 |
|
188 | APEX Nitro enables this feature automatically. There is no way and no need to disable it.
|
189 |
|
190 | ### Theme Roller Customization
|
191 | Theme Roller was introduced in APEX 5.0 as a way to quickly change the look and feel of an application. Under the hood, Theme Roller is simply toggling CSS classes to your APEX components. The CSS of your application takes care of styling the appropriate classes.
|
192 |
|
193 | ![](img/feature-themeroller-0.jpg)
|
194 |
|
195 | For Theme Roller to be dynamic, it needs variable support, so that the color you picked in the color picker applies to multiple selectors in the CSS code. Theme Roller uses Less, a CSS preprocessor, to achieve that. Less allows the use of variables, and then compiles to CSS on the fly so your browser can understand the stylesheet.
|
196 |
|
197 | APEX Nitro is highly compatible with APEX Theme Roller providing a way to add custom Theme Roller attributes to an application. This is disabled by default to reduce the initial complexity of using APEX Nitro.
|
198 |
|
199 | Here how to use it
|
200 |
|
201 | 1. To enable it, select a CSS preprocessor for your application (using Sass in this example).
|
202 | ![](img/feature-themeroller-1.png)
|
203 |
|
204 | 2. Have one of your (Sass, Less) files contain variables. [Related blog post for more info.](http://vmorneau.me/customizing-theme-roller/) Example:
|
205 | ```sass
|
206 | /*
|
207 | {
|
208 | "translate": false,
|
209 | "groups":[
|
210 | {
|
211 | "name": "Global",
|
212 | "common": true,
|
213 | "sequence": 1
|
214 | }
|
215 | ]
|
216 | }
|
217 | */
|
218 |
|
219 | /*
|
220 | {
|
221 | "var": "@background-color",
|
222 | "name": "Body Background",
|
223 | "type": "color",
|
224 | "style": "big",
|
225 | "group": "Global"
|
226 | }
|
227 | */
|
228 | $background-color: #efefef;
|
229 |
|
230 | body {
|
231 | background-color: $background-color;
|
232 | }
|
233 | ```
|
234 |
|
235 | 3. Have the APEX Nitro project configuration to list all your (Sass, Less) files inside the Theme Roller section. This will tell APEX Nitro to compile a Theme Roller compatible file based on your variables. This file will be named `themeroller.less`.
|
236 | ![](img/feature-themeroller-2.png)
|
237 |
|
238 | 4. Reference `themeroller.less` from step 3 in your application's theme style.
|
239 | ![](img/feature-themeroller-3.png)
|
240 |
|
241 | Now when you open Theme Roller on your application, you should see your new variables too.
|
242 |
|
243 | ### Responsive Development
|
244 | Due to the nature of the APEX builder, most APEX developers approach their application with a "Desktop first" design, which goes against the popular "Mobile first" trend these days.
|
245 |
|
246 | APEX Nitro allows to simulate the testing of multiple devices at once.
|
247 |
|
248 | By activating the Ghost Mode option of your project configuration, you can make responsive design development much easier.
|
249 | ![](img/feature-responsive-1.png)
|
250 |
|
251 | Then when you do `apex-nitro launch <project>`, look for the external URL:
|
252 | ![](img/feature-responsive-2.png)
|
253 |
|
254 | By going to that URL on the same network, all devices synchronize together as far as navigating, clicking, typing and scrolling.
|
255 |
|
256 | Try it yourself.
|
257 |
|
258 | ### Automatic Heading
|
259 | This is particularly useful to tag your files with the version of your application. APEX Nitro injects the content of a JSON file into the compiled version of your CSS and JavaScript.
|
260 |
|
261 | **Example:**
|
262 | 1. `/project/demo-header.json`
|
263 | ```javascript
|
264 | {
|
265 | "name": "demo-header",
|
266 | "version": "1.0.0",
|
267 | "author": "OraOpenSource",
|
268 | "description": "Demo App for APEX Nitro demo header",
|
269 | "license": "MIT"
|
270 | }
|
271 | ```
|
272 |
|
273 | 2. `/project/src/js/app.js`
|
274 | ```javascript
|
275 | (function(){
|
276 | console.log("demo-header");
|
277 | })();
|
278 | ```
|
279 |
|
280 | **Compiles to:**
|
281 | 1. `/project/dist/js/app.min.js`
|
282 | ```javascript
|
283 | /*!
|
284 | * demo-header - Demo App for APEX Nitro demo header
|
285 | * @author OraOpenSource
|
286 | * @version v1.0.0
|
287 | * @link
|
288 | * @license MIT
|
289 | */
|
290 | !function(){console.log("demo-header")}();
|
291 | ```
|
292 |
|
293 | [This example is also shown here.](../examples/demo-header)
|