
ui5-tooling
entered the stage, the UI5-verse had baked many handcrafted solutions for allowing local UI5 development. There were (and still are!) many shades of skillful tool combinations, from grunt
to gulp
to node
-scripts, that served resources, proxied requests and generated sources.ui5-tooling
changed that: a toolkit, released and maintained by the UI5 team, positioned to be the go-to instrument for local UI5 development.ui5 serve
the local UI5 application with locally installed UI5 sources (via npm
)ui5 build
the local UI5 application, forComponent-preload.js
npm
modules for reuse or in git
as a template to create own middlewares and tasks.yarn dev
and off it goes:Talk is cheap, show me the code:
- Example showcase at https://github.com/petermuessig/ui5-ecosystem-showcase
npm
module searches:
middlewares via https://www.npmjs.com/search?q=ui5-middleware ,
task via https://www.npmjs.com/search?q=ui5-task
ui5-middleware-cfdestination
: reuse destinations set up in SAP CP Cloud Foundry for local proxyingui5-middleware-livereload
: automatic stateful reload of UI5 application when source files changeui5-middleware-livetranspile
: transparent transpilation of ES6
+ JS sources during ui5 serve
ui5-middleware-simpleproxy
: simple proxy for remote systems, fulfilling browser runtime CORS policyui5-task-transpile
: transpile ES6
+ JS sources for ui5 build
npm
modules for middleware and tasksui5-server
can be used with npm
: install a module, then configure it for use with ui5 serve
.ui5-tooling
$> npm install --global @ui5/cli # install ui5-tooling globally
$> npm install --global yarn # we're using yarn over npm in the showcase
$> cd app
$/app> npm init --yes # generate a package.json
$/app> ui5 init # generate ui5.yaml
$/app> npm install @openui5/sap.ui.core, ... # install ui5 libs
npm
(or yarn
😞$/app> npm install ui5-middleware-livereload --save-dev # custom middleware extension, yay!
package.json
ui5.yaml
// package.json
{
// ...
"ui5": {
"dependencies": [
"ui5-middleware-livereload"
]
}
}
// ui5.yaml
// ...
server:
customMiddleware:
- name: ui5-middleware-livereload
afterMiddleware: compression
configuration:
debug: true
port: 35729
path: webapp
ui5 serve
in your /app
directory, you should see the middleware light up in your console:info middleware:custom:livereload Livereload connecting to port 35729 for path webapp
Watching /path/to/app/webapp...
info middleware:custom:livereload Livereload server started...
Server started
js
-file (or css
, html
, xml
, properties
, ...) will trigger a live reload of the app - in all (!) browsers having the app open. See the documentation of ui5-middleware-livereload
for further information on the middleware.ui5.yaml
) for a comprehensive example.function
signature, whether it's a middleware or a task:/**
* Custom UI5 Server middleware example
*
* @param {Object} parameters Parameters
* @param {Object} parameters.resources Resource collections
* @param {module:@ui5/fs.AbstractReader} parameters.resources.all Reader or Collection to read resources of the root project and its dependencies
* @param {module:@ui5/fs.AbstractReader} parameters.resources.rootProject Reader or Collection to read resources of the project the server is started in
* @param {module:@ui5/fs.AbstractReader} parameters.resources.dependencies Reader or Collection to read resources of the projects dependencies
* @param {Object} parameters.options Options
* @param {string} [parameters.options.configuration] Custom server middleware configuration if given in ui5.yaml
* @returns {function} Middleware function to use
*/
module.exports = function({resources, options}) {
return (req, res, next) => {
// [...]
}
};
function
signature is connect- and express-compatible. So all middleware suitable for those two frameworks are in principal compatible to ui5-server
as well!js
-file(s) need to go into a folder with a dedicated name, containing several mandatory files. Take ui5-middleware-livereload
as an example:ui5-middleware-livereload
├── README.md
├── lib
│ └── livereload.js
├── node_modules
├── package.json
└── ui5.yaml
ui5.yaml
describes the extension and is self-explanatory:specVersion: '1.0'
metadata:
name: ui5-middleware-livereload
kind: extension
type: server-middleware
middleware:
path: lib/livereload.js
package.json
is an npm
-standard like file for describing the packagenpm
module.ui5-tooling
extensions, be it tasks or middlewares.npm
. Follow the naming convention ui5-{middleware|task}-{name}
.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
2 | |
2 |